Free Tools
By Fadhil Abdulla

HEX, RGB, HSL, CMYK and OKLCH: Color Formats Explained

What each colour format means, when designers, developers and printers use them, and how to convert between them accurately.

Editorial disclosure: Pyalm publishes and maintains the products and free tools discussed on this site. Regulatory statements are linked to primary sources where applicable. No independent professional review is claimed unless a reviewer is explicitly named.

The same green can be written as #2E8B57, rgb(46, 139, 87), hsl(146, 50%, 36%), cmyk(67%, 0%, 37%, 45%) or oklch(55% 0.12 155). They're different ways of describing one colour, each suited to a different job.

The formats

HEX

Six hex digits for red, green and blue: #RRGGBB. Compact and the default in design tools and CSS. #2E8B57 = red 0x2E (46), green 0x8B (139), blue 0x57 (87).

RGB

The same three channels as decimal 0–255. Use rgb(46 139 87 / 50%) for transparency.

HSL

Hue (0–360° around the colour wheel), saturation (0–100%) and lightness (0–100%). Easy for humans to tweak: make a colour lighter by raising L, more muted by lowering S.

HSV / HSB

Hue, saturation and value/brightness — what most colour pickers in Photoshop and Figma show.

CMYK

Cyan, magenta, yellow and black ink percentages for print. Conversion from RGB depends on the printer's colour profile; a simple formula is a starting point, not a press-ready value.

OKLCH

A modern CSS colour space with perceptually uniform lightness, chroma and hue. Two colours with the same L genuinely look equally light — HSL can't promise that (yellow at 50% lightness looks far brighter than blue at 50%). OKLCH makes consistent colour scales and accessible palettes much easier, and works in all modern browsers.

Which to use where

Job Format
Handing over brand colours HEX + CMYK (and Pantone for print-critical work)
Writing CSS HEX, RGB or OKLCH
Generating tints/shades HSL or OKLCH
Print CMYK from the printer's profile
Tailwind arbitrary values bg-[#2E8B57]

Convert instantly

Paste any format — even a CSS name like seagreen — into the free Color Converter to get every other format, a tints-and-shades scale and a WCAG contrast check.

Contrast in one minute

The contrast ratio compares the relative luminance of two colours, from 1:1 (identical) to 21:1 (black on white). WCAG AA needs 4.5:1 for normal text and 3:1 for large text and UI components.

Rather have it built?

Pyalm designs and builds fast, conversion-focused websites in Next.js — the same stack these tools run on — with a consistent design system, accessible colours and technical SEO built in.

Color Palette Generator | Color Converter | Box Shadow Generator | Flexbox Playground | All free tools

Keep reading

More from Pyalm

Oct 16, 2026

How to Format and Validate JSON (and Fix the 6 Most Common Errors)

Why JSON breaks, how to read a validator's error message, and a quick routine for pretty-printing, minifying and fixing JSON from APIs, logs and config files.

Oct 16, 2026

How to Compare Two JSON Files (Without Drowning in Diff Noise)

Text diffs flag reordered keys and whitespace as changes. Here's how a structural JSON comparison works, and how to use it to review API changes, configs and migrations.

Oct 16, 2026

Regex Cheat Sheet with Real Examples (Emails, Phones, Dates, UAE TRN)

A practical regular expression cheat sheet — the syntax you actually use, plus tested patterns for emails, UAE and Indian phone numbers, dates and tax numbers.

Oct 16, 2026

URL Encoding Explained: %20, + and When to Encode

What percent-encoding is, why spaces become %20, the difference between encodeURI and encodeURIComponent, and how to avoid double-encoding bugs.

Oct 16, 2026

Unix Timestamps Explained: Epoch Time, Seconds vs Milliseconds and Time Zones

What epoch time is, why it's the standard way to store dates, how to tell seconds from milliseconds, and how to avoid the time-zone bugs it causes.

Oct 16, 2026

Minify vs Beautify: What Code Minification Does and When to Use It

How minifying JavaScript, CSS and HTML shrinks files, how much it really saves, and when to beautify minified code to debug it.

Try the free Color Converter & Contrast Checker

Pyalm designs and builds fast, conversion-focused websites in Next.js — the same stack these tools run on. If you'd rather have it built than fiddle with CSS, talk to us.

Open Color Converter & Contrast Checker See website development All free tools