A practical color workbench

HTML Color Codes

Pick a color, convert its code, and see how it reads on your background. Explore variations and collect up to 12 colors for a ready-to-use CSS palette.

How to use HTML color codes

  1. Enter a foreground color and an opaque background, or use the visual pickers.
  2. Select Convert & check contrast to get HEX, RGB and HSL values plus text contrast results.
  3. Copy a code, try a variation, or add the color to your palette. Export the palette as CSS custom properties.

“HTML color codes” usually means CSS color values used to style HTML. For example, color: #203f5e; sets text color and background-color: #fffaf7; sets its background. A name such as rebeccapurple is equivalent to #663399.

Which formats can I enter?

FormatExample
HEX, with or without ##639, #66339980
CSS namerebeccapurple, transparent
RGB / RGBArgb(102 51 153 / 50%)
HSL / HSLAhsl(270, 50%, 40%)

HEX accepts 3, 4, 6 or 8 digits; alpha comes last. RGB channels must be 0–255 or 0–100%. HSL saturation and lightness require percentages from 0–100%; hue accepts degrees, turns, radians and gradians, and wraps around the color wheel. Alpha must be 0–1 or 0–100%. Names are case-insensitive, including gray/grey aliases.

Both comma-separated and modern space-separated functions work. Use a slash before alpha in space syntax. Do not mix separators. This focused converter rejects out-of-range channels instead of silently clamping them as CSS can. It does not parse var(), calc(), currentColor, system colors, none, relative colors, HWB, Lab, OKLCH or wide-gamut values.

Read the result accurately

The color codes describe your foreground, including its alpha. The large swatch and text sample show its appearance on the selected background. A half-transparent black foreground on white appears gray; it does not have the contrast of opaque black. The effective HEX is rounded for display only.

AA text contrast needs at least 4.5:1 for normal text or 3:1 for large text. AAA needs 7:1 or 4.5:1 respectively. A displayed ratio may round to a threshold while still failing, so the pass/fail label uses the original value. Gradients, images, blend modes, overlapping layers, font weight and the surrounding page need separate review. HSL lightness is not perceived brightness, and color harmonies alone do not establish readability.

Privacy and standards

The tool calculates in your browser and makes no requests with your color values. It adds no cookies or persistent storage. The shared site's analytics and privacy policy still apply. Clipboard access happens only after you choose a copy action; no clipboard contents are read. Downloads are generated in your browser.

Color syntax and named values follow CSS Color Level 4 within the supported subset. Contrast follows WCAG 2.2 minimum contrast and enhanced contrast, with source-over alpha compositing against the opaque background. Color appearance can vary between screens.