CSS Color Name to Hex
Convert a standard CSS named color like cornflowerblue into its 6-digit hex code — an exact lookup across all 147 CSS Color Module names.

Built by
Swapnil SanghviFull-Stack Web Developer & WordPress Developer
Swapnil Sanghvi is a full-stack web and WordPress developer, UI designer, and full-time freelancer who builds and maintains Hex Calculator.
Further reading: CSS Colors — W3Schools
How CSS Color Name to Hex Conversion Works
The CSS Color Module spec defines a fixed hex value for each of its roughly 147 named colors. This tool looks up your color name — case-insensitively — against that list and returns the exact 6-digit hex code, the same value every standards-compliant browser renders for that name.
CSS Color Name to Hex Example, Step by Step
cornflowerblue = #6495ED
cornflowerblue (CSS color name) = #6495ED (hex)
Name input: cornflowerblue Look up against the 147 CSS Color Module names Fixed hex value: #6495ED
| Step | Description | Result |
|---|---|---|
| Take the color name | cornflowerblue | cornflowerblue |
| Normalize case | lowercase for lookup | cornflowerblue |
| Look up in the CSS spec table | find the defined hex value | #6495ED |
| Return the hex code | always 6 digits | #6495ED |
Unlike the reverse direction, every valid CSS color name has exactly one defined hex value — there's no ambiguity to resolve here.
Where CSS Color Name to Hex Actually Comes Up
Migrating Legacy CSS to Hex or Variables
Older stylesheets that use keyword colors like tomato or cornflowerblue need those converted to hex when moving to a design-token or CSS-variable-based system.
cornflowerblue -> #6495ED
Verifying a Named Color Before Using It
Before committing to a CSS keyword color in a component, checking its exact hex value confirms it matches the shade you actually intend, rather than guessing from the name alone.
rebeccapurple -> #663399
Documenting a Design System's Base Palette
Style guides that reference standard CSS color names still need the hex values documented for teams working in tools that don't recognize CSS keywords directly.
named color -> hex for style guide
Common Mistakes With CSS Color Name to Hex
- Typing a non-standard name like "skyblue2" or a design tool's custom label, which isn't part of the CSS spec.
- Assuming British and American spellings both work for every color — grey and gray are both valid, but that's an exception, not the rule.
- Confusing a CSS color name with a Tailwind or Bootstrap palette name — those are separate naming systems with different hex values.
Why Use This Calculator Instead of Looking It Up Yourself
- Covers all ~147 CSS Color Module names, not just the common ones
- Runs entirely in your browser — nothing you type gets sent anywhere
- Matches case-insensitively, exactly like browsers do
- Flags unrecognized names instead of guessing
Limitations
- Recognizes all 147 standard CSS Color Module names, including both spellings where they differ (gray/grey) — but not vendor-specific or non-standard color names outside that list.
Frequently Asked Questions
What CSS color names does this tool support?
All roughly 147 standard names from the CSS Color Module spec, from common ones like red and blue to less familiar entries like cornflowerblue and rebeccapurple.
What's the hex code for cornflowerblue?
#6495ED — a fixed value defined by the CSS Color Module spec, the same in every standards-compliant browser.
Are CSS color names case-sensitive?
No — CornflowerBlue, cornflowerblue, and CORNFLOWERBLUE all resolve to the same hex code, both in browsers and in this tool.
What happens if I enter a color name that doesn't exist?
The tool returns an error, since only the standard CSS Color Module names have a defined hex value to look up.
What's the hex code for rebeccapurple?
#663399 — a named color added to the CSS spec in 2014 in memory of Rebecca Meyer, Eric Meyer's daughter.
I inherited old CSS with color names in it — how do I standardize it to hex?
Look up each named color here and replace it with its hex equivalent — useful when migrating a legacy stylesheet to a design system that requires hex or CSS variable values instead of keyword colors.
Does every browser render a given CSS color name identically?
Yes — the CSS Color Module spec fixes an exact hex value for each name, so red always renders as #FF0000 in every standards-compliant browser, with no variation.