HEX to Nearest HTML Color Name

Nearest of sixteen HTML4 basic named colors by encoded 8-bit RGB squared distance; ties retained, not full CSS/X11 table or perceptual distance.

Description

HEX to Nearest HTML Color Name: return nearest html4 names, squared encoded distance.

A named-color match depends on the available palette and distance measure. A nearest match in encoded RGB is not necessarily the nearest perceived color.

This tool returns nearest html4 names, squared encoded distance. Use the stated units and model convention when interpreting these fields.

When to use this tool

Use this tool when the supplied inputs match the specific operation described above and you need a repeatable result under its stated convention.

  • Check the supported input and output contract against an existing calculation or observation.
  • Use the complete example to confirm units, selector spelling and result interpretation.

How to use the tool and how it works

  1. Enter every field in the input table using the stated units and the exact supported selector spelling where applicable.
  2. Run the tool. Correct input errors before interpreting an output.
  3. Read the result fields below; use accompanying flags and the stated sign, boundary or model convention when interpreting a number.

Parse an exact six-digit HEX color. Compute squared Euclidean distances to the stored sixteen HTML4 swatches, then return every tied nearest name and the squared distance.1

Input fieldMeaning and unitsAccepted input
hexSrgbHex srgb.Text
Output fieldInterpretation
resultObject containing the following named result fields.
result.nearestHtml4NamesNearest html4 names list, in the ordering described in the calculation.
result.squaredEncodedDistanceSquared encoded distance; use the stated units and sign convention.
json
{
  "input": {
    "hexSrgb": "#FF0000"
  },
  "output": {
    "result": {
      "nearestHtml4Names": [
        "red"
      ],
      "squaredEncodedDistance": 0
    }
  }
}

Limitations and assumptions

  • The tool does not search the complete CSS named-color set or use a perceptually uniform color-difference model.
  • Every declared field is required and unexpected fields are rejected. Numeric inputs must be finite; input errors are distinct from a valid false result or an explicitly qualified output.
  • Extremely large inputs and nonfinite or excessively large outputs are rejected. List positions reported by the tool use zero-based indices unless stated otherwise.

Alternative or Complementary methods

Check the underlying observations, units and conventions independently before using the result in a larger workflow. The tools listed below address nearby tasks; compare their inputs and scope before substituting one for this operation.

References

  1. Tool behavior and example: HEX to Nearest HTML Color Name — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies