HEX to Color Name (Nearest Named Color)
A color name is a plain English label, such as purple or teal, that the CSS standard maps to a fixed RGB value. A hex code like #9b59b6 is precise but unreadable, so this tool reads any hex value and returns the closest CSS named color, along with its exact RGB and HSL numbers, so you can describe a color in words instead of digits.
What a Named Color Is and the CSS Named Color Set
A named color is a keyword that the CSS specification ties to one specific RGB value. The keyword red always means rgb(255, 0, 0), and teal always means rgb(0, 128, 128). The full set includes roughly 140 keywords, from the basic black, white, and blue to descriptive names such as tomato, orchid, and slategray. Because the set is fixed and finite, most hex codes fall somewhere between two named colors rather than on one of them, which is why a tool reports the nearest name instead of an exact match.
How to Use It
- Type a hex code into the field, with or without the leading hash. Both short form (#fff) and long form (#ffffff) work.
- Or click the color picker and choose a shade. The hex field syncs to your selection.
- Read the nearest CSS color name shown in large text, next to a swatch of your exact color.
- Check the RGB and HSL values in the list to use the color in code.
- Note the distance reading. A distance of zero means the hex is an exact named color; anything higher means it is the closest name only.
How Nearest-Color Matching Works
HEX vs RGB vs HSL
| Format | Looks like | Best for |
|---|---|---|
| HEX | #9b59b6 | Compact codes in CSS and design tools |
| RGB | rgb(155, 89, 182) | Reading the exact red, green, and blue channels |
| HSL | hsl(282, 39%, 53%) | Adjusting hue, saturation, or lightness by hand |
All three describe the same color. HEX and RGB carry identical information in different notation, while HSL re-expresses that color as a hue angle, a saturation percentage, and a lightness percentage, which is easier to reason about when you want to lighten or shift a shade.
Why There Is Not Always an Exact Name
The 24-bit color space holds more than 16 million distinct values, while the CSS named set holds about 140. Almost every hex code you encounter, especially one produced by a design tool or sampled from an image, sits in the gap between named colors. The nearest-name result tells you which keyword is closest so you can describe the color in words, but for accurate work you still use the exact hex, RGB, or HSL value.
When to Use It
Reach for this tool when you need to name a color for a label, a class, or a conversation, when you want to confirm whether a hex value is an official CSS keyword, or when you are translating a sampled color into something a teammate can picture. To choose a new color from scratch, use the color picker; to build a coordinated set, use the color palette generator.
Last Thoughts on Naming a HEX Color
A hex code is exact but silent about what the color actually looks like. Mapping it to the nearest CSS name gives you a word you can read, say, and remember, while the RGB and HSL values keep the precision you need for code. The two work together: the name for people, the numbers for machines.
Convert your next hex value to its nearest name above, then continue with the color picker, build a set with the color palette generator, or blend two shades with the CSS gradient generator. Explore the rest of our free online tools.
Key Takeaways:
- A named color is a CSS keyword tied to one fixed RGB value; the set holds about 140 names.
- Most hex codes fall between named colors, so the result is the nearest name, exact only when the distance is zero.
- Nearest matching uses Euclidean distance across the red, green, and blue channels.
- HEX and RGB carry the same information; HSL re-expresses it as hue, saturation, and lightness.
- Type a hex code or use the color picker; the name, swatch, RGB, and HSL update with no button.
- Use the name for people and the exact hex, RGB, or HSL values for code.
Frequently Asked Questions (FAQs)
How does this tool find the color name?
It treats each color as a point in three-dimensional RGB space and measures the straight-line distance from your hex value to every named CSS color. The name with the smallest distance is the closest match. When that distance is zero, the hex code is an exact named color.
Why is the result called the nearest name and not the exact name?
There are over 16 million possible hex colors but only about 140 named ones, so most hex codes do not land on a name. The tool reports the closest keyword so you can describe the color, but it is exact only when the reported distance is zero.
Can I enter a short hex like #fff?
Yes. The tool accepts both the three-digit short form, such as #fff, and the six-digit long form, such as #ffffff, with or without the leading hash. It expands the short form internally before matching.
What do the RGB and HSL values mean?
RGB lists the red, green, and blue channels from 0 to 255. HSL re-expresses the same color as a hue angle, a saturation percentage, and a lightness percentage, which is easier to adjust by hand. All three describe the same color in different notation.
Is my color sent to a server?
No. The matching runs entirely in your browser using a built-in table of named colors. Nothing you type or pick is uploaded, logged, or stored anywhere, so the tool works even with no internet connection.
What happens if I enter an invalid hex?
The tool shows an invalid notice and waits. It only accepts three or six hexadecimal digits, so a typo or a partial code is ignored until the value is valid, at which point the result updates on its own.


