Hex to color name
Put a name to a hex code: #ff5733 is closest to tomato, whose own code is #ff6347, picked from 148 CSS named colors by distance in RGB space. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Hex
- #ff5733
- Resistance (Ω)
- 255
- G
- 87
- B
- 51
- Name
- tomato
Design tokens, brand guidelines, and style sheets often store colors as hex codes, yet humans still talk in names such as tomato, cornflowerblue, or rebeccapurple. This tool takes a single CSS hex value—three or six hexadecimal digits, with or without a leading hash—and returns the nearest solid CSS named color from the CSS Color Module Level 4 palette by Euclidean distance in eight-bit red-green-blue space. When the hex already matches a named color exactly, the response marks exact true and the distance is zero. When it sits between keywords, you still get a stable closest name, the keyword’s own hex and channels, and a numeric distance so design reviews and lint rules can decide how close is close enough. Invalid hex strings fail with a clear validation error instead of inventing a name.
How nearest CSS named colors are chosen
Every solid CSS named color is a fixed triple of red, green, and blue channel values from zero through two hundred fifty-five, published in the CSS Color Module Level 4 keyword table. Your input is normalized: optional leading hash, lowercased hex digits, and three-digit shorthand expanded by doubling each nibble so that f zero zero becomes f f zero zero zero zero. The algorithm then measures Euclidean distance in RGB space: the square root of the sum of squared channel differences between your color and each named triple.
The name with the smallest distance wins. When two keywords share the same RGB values—for example aqua and cyan, or fuchsia and magenta—or when two distinct triples happen to sit at the same numeric distance, the alphabetically first name is kept so the result never flips between runs. Distance zero means an exact palette hit and the exact flag is true; a positive distance means a nearest-neighbor approximation you can still use in copy, accessibility notes, or soft palette linting.
What you send and what you get back
Send one string field named hex. Accepted shapes are six-digit codes such as hash f f five seven three three, three-digit shorthand such as hash f zero zero, and the same strings without a leading hash. Spaces around the value are trimmed.
Classic checks include pure red as hash f f zero zero zero zero resolving to red with exact true; near-orange hash f f five seven three three resolving near tomato with a positive distance; and bare six-digit codes without a hash resolving the same as their hashed form.
Where hex-to-name lookup shows up in real work
Design systems and brand books often publish primary and accent colors as hex while product copy, accessibility annotations, and stakeholder slides need human-readable names for the same swatches. Front-end lint rules and CI checks can flag custom hex values that sit far from any CSS keyword when a team prefers named colors in stylesheets for readability. Data-visualization authors mapping categorical series sometimes start from hex ramps and want the closest CSS keyword for legends that must render without custom swatch images.
If you later need multi-format conversion across HEX, RGB, HSL, LAB, and CMYK, reverse conversion from names to hex only, dominant color extraction from images, or WCAG contrast checks, treat those as separate search intents and landings rather than overloading this dedicated hex-to-color-name page.
What you can do with it
Name brand hex tokens for docs
Map design-token hex values to the closest CSS keyword for style guides, handoff notes, and stakeholder-friendly color tables.
Lint styles toward named colors
Score custom hex declarations by distance to the CSS palette and flag outliers when a team prefers readable named colors in CSS.
FAQ
How is the nearest CSS color name chosen?
The tool parses your hex into 8-bit RGB, then picks the CSS Color Module Level 4 solid named color with the smallest Euclidean RGB distance. Ties keep the alphabetically first name.
Which hex formats are accepted?
Three-digit and six-digit hex codes, with or without a leading #.
What does exact true mean?
Your hex matches a named color’s RGB values exactly, so distance is zero. Otherwise exact is false and distance is the Euclidean gap to the nearest keyword.
Does this convert HEX to RGB or HSL?
No. It only finds the nearest CSS named color. For multi-format conversion use the general color converter landing; this page owns the hex-to-name search intent.
What does it cost?
The browser tool is free and runs locally.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/color/hex-name \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"hex":"#ff5733"}'const res = await fetch("https://api.kit.forhosting.com/color/hex-name", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"hex": "#ff5733"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/color/hex-name",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"hex": "#ff5733"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/color/hex-name", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"hex":"#ff5733"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"hex":"#ff5733"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/color/hex-name", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"hex": "#ff5733"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "color.hex_name",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How nearest CSS named colors are chosen
This capability keeps that full solid palette—including US and UK spelling aliases such as gray and grey, and modern keywords such as rebeccapurple—and excludes transparent because a plain hex code has no alpha channel. The entire path is deterministic floating-point arithmetic with no random seeds, no wall-clock timestamps, and no network calls, so identical hex inputs always produce identical JSON.
What you send and what you get back
Non-hex characters, empty strings, four-digit or eight-digit alpha forms, and non-string types fail with invalid_input and are not charged. On success the response echoes a normalized lowercase six-digit hex with a leading hash, integer channels r, g, and b for the input, the winning CSS name, the named color’s own named_hex and named_r, named_g, named_b channels, a cleaned floating distance, a boolean exact flag, the palette_size of the solid keyword table, and a short formula note describing Euclidean RGB distance with alphabetical tie-breaking. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where hex-to-name lookup shows up in real work
Content tools that generate alt text, theme descriptions, or documentation tables from token JSON need a stable nearest name rather than a free-form model guess. Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.
Integration use cases
Bulk hex tables for content tools
Convert large hex lists from theme JSON into stable nearest names for legends, alt text helpers, and curriculum answer keys.