Color Converter
Convert any CSS color between HEX, RGB, HSL, HSV and OKLCH instantly. Includes live WCAG contrast check and a click-to-load tints & shades palette.
WCAG Contrast
Tints & Shades
How to use the Color Converter
Type or paste any CSS color into the input field and the tool converts it to all supported formats in real time. Use the native color picker beside the input to explore colors visually, both controls stay in sync. For a quick start, click Load sample to see all outputs populated with an example color.
- Enter any color, paste a HEX code, an
rgb(),hsl()oroklch()value, or a CSS named color such asrebeccapurple. The format is auto-detected. - Read the format outputs, HEX, RGB, HSL, HSV, OKLCH and a CSS custom property snippet appear instantly below the input.
- Copy any format with its dedicated Copy button. The button confirms with "Copied!" for 1.5 seconds.
- Check the WCAG contrast, the right panel shows the contrast ratio of your color against white and dark text, with AA and AAA pass/fail grades for both normal and large text sizes.
- Explore the palette, click any of the 11 tints or shades to load it into the input and see its full set of conversions.
- Use the color picker, click the swatch beside the input to open the native browser picker and select visually. The text field updates to the chosen hex value automatically.
What makes OKLCH the modern choice for design systems
Most color spaces used in CSS, including HEX, RGB and HSL, are based on the sRGB model, which was designed for display hardware rather than human perception. OKLCH (Oklab Lightness-Chroma-Hue) was designed to be perceptually uniform: two colors that are numerically equidistant in OKLCH look visually equidistant to a human observer. This property makes it uniquely reliable for generating accessible color scales, ensuring that each step in a palette has a predictable visual jump. CSS natively supports oklch() in all modern browsers as of 2023, and design systems like Radix UI and Tailwind v4 have adopted it for this reason. For more on accessible design, check the CSS Gradient Generator to build gradients using the same OKLCH palette you create here.
Understanding WCAG contrast grades
The Web Content Accessibility Guidelines (WCAG) 2.1 define contrast requirements to ensure text remains readable for users with low vision. AA requires a contrast ratio of at least 4.5:1 for normal-sized text and 3:1 for large text (18pt+ or 14pt+ bold). AAA, the higher standard, requires 7:1 for normal text. The formula uses relative luminance: a linearized measure of how much light a color reflects, where pure black is 0 and pure white is 1. This tool always tests your color against both white (#fff) and near-black (#0f172a) so you can instantly see which text color paints the more accessible option.
Frequently asked questions
What color formats does this converter support?
The converter supports HEX (3-digit, 6-digit and 8-digit with alpha), RGB and RGBA (comma or space syntax), HSL and HSLA, OKLCH, and any valid CSS named color such as cornflowerblue, rebeccapurple or tomato. The format is auto-detected as you type, so you can paste any of these directly into the input field without selecting a mode first.
What is OKLCH and why should I use it instead of HSL?
OKLCH is a perceptually uniform polar color space defined by lightness (L), chroma (C) and hue (H). Unlike HSL, where colors with identical lightness values can look visually very different in perceived brightness, OKLCH uses an underlying model that better matches how human vision perceives color differences. This makes it ideal for programmatically generating accessible color scales, consistent button palettes and design tokens. CSS natively supports oklch() in all modern browsers as of 2023, and major design systems have adopted it for this precision. You can pair OKLCH values directly with the CSS Gradient Generator for perceptually smooth gradients.
How is the WCAG contrast ratio calculated?
The contrast ratio uses the WCAG 2.1 formula: (L1 + 0.05) / (L2 + 0.05), where L1 is the relative luminance of the lighter color and L2 is the relative luminance of the darker color. Relative luminance is calculated from linearized sRGB channel values weighted as 0.2126 R + 0.7152 G + 0.0722 B. The tool checks your color against pure white (255, 255, 255) and near-black (15, 23, 42) and displays the ratio alongside the WCAG grade for both normal and large text.
What do the AA and AAA accessibility grades mean?
WCAG 2.1 defines two conformance levels for text contrast. Level AA requires a ratio of at least 4.5:1 for normal text and 3:1 for large text (18pt+ or 14pt+ bold). Level AAA requires 7:1 for normal text and 4.5:1 for large text. AA is the legal minimum in many accessibility regulations including EN 301 549 and Section 508. AAA is recommended for documents or interfaces where maximum readability matters, such as medical or legal content.
How does the tints and shades palette work?
The palette converts your color to HSL space, then generates five tints by interpolating the lightness toward 95% (near white) and five shades by interpolating toward 5% (near black), keeping hue and saturation constant. The result is an 11-swatch strip: 5 tints, your base color (outlined in the palette), and 5 shades. Clicking any swatch immediately loads that color into the input for further conversion or WCAG inspection.
Is my color data sent to a server?
No. All color parsing, conversion math and WCAG calculations run entirely in your browser using JavaScript. PureTools has no server endpoint for this tool and never receives the colors you enter. The last color you typed is saved in sessionStorage under a namespaced key so it persists on refresh, but sessionStorage is automatically cleared when you close the tab, so data is erased when you close the tab. Nothing is ever uploaded or stored remotely. Your data is never used to train AI models or improve machine learning systems.
Can I paste a color copied from Figma or browser DevTools?
Yes. Figma typically copies colors as HEX, HSL or RGB. Browser DevTools copy colors as hex, rgb() or hsl(). All of these are accepted directly. If you copy an oklch() value from a CSS file or a design token JSON, that is also supported. The tool auto-detects the format from the pasted string, so you do not need to select anything before pasting. You can also use the JSON Formatter to extract color values from design token JSON files before pasting them here.
What is the difference between HSL and HSV?
Both HSL (Hue, Saturation, Lightness) and HSV (Hue, Saturation, Value) represent colors using a hue angle and two relative axes, but they define the third axis differently. In HSL, a lightness of 50% with maximum saturation gives the pure hue. In HSV, a value of 100% with maximum saturation also gives the pure hue, but value is conceptually closer to perceived brightness. HSL maps more intuitively to how designers think about tints and shades, while HSV is commonly used in color picker wheels and image editing applications.
Why does the converted OKLCH color look slightly different from the original?
sRGB and OKLCH cover similar but not identical gamuts. When you convert sRGB to OKLCH, the values are mathematically exact. When converting back, floating-point rounding in the intermediate matrix multiplications and the cube-root step can produce channel values that are 0 or 1 off in the 0โ255 integer range, a difference that is visually imperceptible. If your input uses a very high-chroma OKLCH value that falls outside the sRGB gamut, the tool clamps the output channel to the nearest valid sRGB value rather than producing invalid CSS.
How does the live color picker stay in sync with the text input?
The native browser color picker (input type="color") always stores its value as hex. Whenever you type a valid color in the text field in any format, the tool converts it to hex and updates the picker's value programmatically. Conversely, picking a color from the swatch writes its hex value into the text field. This two-way sync means you can use the visual picker for exploration and the text field for precision, and both always reflect the same color.
Will my color input be remembered if I refresh the page?
Yes, within the same browser session. The tool saves the last valid input to sessionStorage so it persists on refresh. When you close the tab, sessionStorage is cleared automatically by the browser, so the color is erased and your data stays on your device only. The tool does not use localStorage for color data, only the theme preference is stored there.