Color Picker & Converter
Convert HEX, RGB, HSL, and CMYK. Check WCAG contrast between two colors.
Interactive tool
Color spaces
Screens use RGB (and often HSL for UIs). Print workflows use CMYK. HEX is a shorthand for RGB in web. Contrast ratio compares relative luminance for WCAG accessibility.
How to use
- 1Enter a color in any format chroma.js understands (HEX, RGB, HSL, named colors).
- 2Optionally add a second color to see WCAG contrast ratio.
- 3Copy converted values from the results panel.
Key features
Multi-space output
HEX, RGB, HSL, and CMYK in one step.
WCAG contrast
Ratio for text/background pair checking (higher is more separation).
Why convert locally?
Design tokens and brand colors should not leak to third-party APIs. This tool keeps palette exploration on-device.
Common use cases
- Design system documentation
- Checking button text on brand backgrounds
- Translating brand HEX to CMYK estimates
The hex to RGB formula
- A hex colour is three numbers written in base 16, two digits each. Split the six characters into pairs, read each pair as a number from 00 to FF, and you have the red, green and blue channels as 0 to 255.
- FF is 15 times 16 plus 15, which is 255. So #FF0000 is red 255, green 0, blue 0. A0 is 10 times 16 plus 0, which is 160.
- Three digit shorthand doubles each character rather than padding it: #abc means #aabbcc, not #a0b0c0. That is why #fff is white and not a very dark grey.
- Eight digits add an alpha channel as a fourth pair, so #FF000080 is red at 50% opacity, because 80 in hex is 128 of 255.
Going the other way, RGB to hex
- Convert each channel to base 16 and pad it to two digits. 245 becomes F5, 158 becomes 9E, 11 becomes 0B, giving #F59E0B.
- The padding is the step people miss. A channel value below 16 is a single hex digit, and writing #F59EB instead of #F59E0B produces a five character string that no parser accepts.
Doing it in code
- In CSS you rarely need to convert at all, because modern browsers accept rgb(), hsl() and hex interchangeably, and rgb() now takes an optional alpha after a slash.
- In JavaScript, parseInt(hex.slice(1, 3), 16) reads the red channel, and toString(16).padStart(2, "0") writes one back. The padStart is the part that is usually forgotten.
- In Python, int(hex[1:3], 16) reads a channel and f"{value:02x}" writes one.
- Whichever language, the arithmetic is the same: base 16 in pairs, and pad on the way back.
The same colours in every notation
Hue in HSL is an angle in degrees, and saturation and lightness are percentages. Grey has no meaningful hue, which is why the first three rows read as zero.
| Hex | RGB | HSL | Colour |
|---|---|---|---|
| #FFFFFF | rgb(255, 255, 255) | hsl(0, 0%, 100%) | white |
| #808080 | rgb(128, 128, 128) | hsl(0, 0%, 50%) | mid grey |
| #000000 | rgb(0, 0, 0) | hsl(0, 0%, 0%) | black |
| #FF0000 | rgb(255, 0, 0) | hsl(0, 100%, 50%) | pure red |
| #00FF00 | rgb(0, 255, 0) | hsl(120, 100%, 50%) | pure green |
| #0000FF | rgb(0, 0, 255) | hsl(240, 100%, 50%) | pure blue |
| #F59E0B | rgb(245, 158, 11) | hsl(38, 92%, 50%) | amber |
HSL is worth learning for one reason: to make a colour lighter you change one number, where in hex or RGB you have to move all three and hope the hue survives.
Privacy & security
Color strings are processed in your browser only.
Related tools
- QR Code Generator
Create QR codes for URLs, text, and more. Customize size and colors. Download PNG.
Utilities
- Unit Converter
Convert length, mass, temperature, volume, area, data storage, and speed using convert-units. locally in your browser.
Utilities
- Color Contrast Checker
Check WCAG 2.1 AA and AAA color contrast ratios for text and UI components, with live preview and accessible color suggestions
Utilities
- Percentage Calculator
Calculate percentages with seven modes: percent of, what percent of, increase/decrease, add/subtract percent, and percent difference
Utilities
- Base64 Encoder & Decoder
Encode and decode Base64 strings instantly in your browser
Developer Tools
- Image to PDF
Combine images (PNG, JPEG, WebP) into a single PDF. Drag-drop, reorder, rotate, choose page size and fit mode. All in your browser.
PDF Tools
Frequently Asked Questions
What is WCAG contrast?
It is a luminance ratio used to assess if text contrast is likely readable for many users; higher is stronger separation.
CMYK accuracy?
Screen CMYK is indicative; print proofing still depends on your printer profile.
Privacy?
Parsing uses chroma-js entirely in-browser.
Named colors?
You can type CSS color names chroma recognizes.
Alpha / HSV?
This tool focuses on opaque conversions plus contrast checks.
What is the hex to RGB formula?
Split the six characters into three pairs and read each pair as a base 16 number from 00 to FF, which is 0 to 255. FF is 15 times 16 plus 15, so #FF0000 is red 255, green 0, blue 0. Going back, convert each channel to hex and pad it to two digits.
How do I convert hex to RGB in JavaScript or Python?
In JavaScript, parseInt(hex.slice(1, 3), 16) reads the red channel, and toString(16).padStart(2, '0') writes one back. In Python it is int(hex[1:3], 16) to read and an 02x format string to write. The padding on the way back is the step most often missed.
What does a three digit hex colour mean?
Shorthand doubles each character rather than padding it, so #abc means #aabbcc. That is why #fff is white rather than a very dark grey. An eight digit value adds alpha as a fourth pair, so #FF000080 is red at roughly 50% opacity.