Skip to content

Runs entirely in your browser. Nothing you paste leaves this page.

Free / No sign-up

Color converter: HEX, RGB, HSL, OKLCH, CMYK.

Convert any colour between HEX, RGB, HSL, OKLCH and CMYK, build harmonies, tints and shades in OKLCH, and export a Tailwind-style 50 to 950 scale as CSS variables, a Tailwind v4 theme or JSON.

#1F5EFFvs white 5.12:1
vs black 4.10:1
  • HEX#1f5eff
  • RGBrgb(31 94 255)
  • HSLhsl(223 100% 56%)
  • OKLCHoklch(55.3% 0.247 263.7)
  • CMYKcmyk(88%, 63%, 0%, 0%)

White text reads best on this colour (5.12:1, passes AA for body text). Check any pair in the contrast checker.

Harmony

Tints and shades

50-950 scale

Export format
@theme {
  --color-brand-50: oklch(97% 0.014 263.7);
  --color-brand-100: oklch(93.2% 0.032 263.7);
  --color-brand-200: oklch(88.2% 0.057 263.7);
  --color-brand-300: oklch(80.9% 0.095 263.7);
  --color-brand-400: oklch(70.7% 0.152 263.7);
  --color-brand-500: oklch(62.3% 0.203 263.7);
  --color-brand-600: oklch(55.3% 0.247 263.7);
  --color-brand-700: oklch(48.8% 0.244 263.7);
  --color-brand-800: oklch(42.4% 0.2 263.7);
  --color-brand-900: oklch(37.9% 0.148 263.7);
  --color-brand-950: oklch(28.2% 0.091 263.7);
}

Click any swatch to make it the base colour. Palettes rotate hue in OKLCH so lightness stays even; the scale follows Tailwind v4's lightness curve with your colour at the nearest step (marked •). CMYK is a naive conversion with no print profile.

How to use it.

  1. 01

    Type or paste a colour in any format, such as #1F5EFF, rgb(31 94 255), hsl(224 100% 56%) or oklch(55% 0.24 264), or use the picker.

  2. 02

    Copy the format you need, and browse the harmonies, tints and shades. Click any swatch to make it the new base colour.

  3. 03

    Name the scale, choose Tailwind v4, CSS variables or JSON, and copy the 50 to 950 export into your stylesheet or design tokens.

What it does.

Everything this tool handles, all of it inside your browser tab.

  • Reads HEX (3, 4, 6 or 8 digits), rgb(), hsl(), oklch() and cmyk() in modern or comma syntax
  • Shows HEX, RGB, HSL, OKLCH and CMYK at once, each with a copy button
  • Harmonies in OKLCH: complementary, analogous, triadic, split-complementary and tetradic
  • Tints and shades with even perceptual steps
  • Tailwind-style 50 to 950 scale that keeps your exact colour at the nearest step
  • Exports a Tailwind v4 @theme block, CSS custom properties or JSON tokens
  • Out-of-gamut colours mapped into sRGB by reducing chroma
  • WCAG contrast against white and black for the base colour, linked to the contrast checker
  • Click any swatch to make it the new base colour

Worked examples.

  • One colour in five formats

    HEX    #1f5eff
    RGB    rgb(31 94 255)
    HSL    hsl(223 100% 56%)
    OKLCH  oklch(55.3% 0.247 263.7)
    CMYK   cmyk(88%, 63%, 0%, 0%)

    All five describe the same sRGB colour. OKLCH is the one to reach for when you need to make lighter, darker or related colours.

  • Same HSL lightness, very different brightness

    hsl(60 100% 50%)   yellow   oklch(96.8% 0.211 109.8)
    hsl(240 100% 50%)  blue     oklch(45.2% 0.313 264.1)

    Both claim 50% lightness. OKLCH shows the real perceived difference, which is why HSL palettes have uneven contrast.

  • Tailwind v4 theme export

    @theme {
      --color-brand-50: oklch(97% 0.014 263.7);
      --color-brand-100: oklch(93.2% 0.032 263.7);
      …
      --color-brand-600: oklch(55.3% 0.247 263.7);
      …
      --color-brand-950: oklch(28.2% 0.091 263.7);
    }

    Paste into your main CSS file after @import "tailwindcss" and you get bg-brand-50 to text-brand-950 utilities.

  • Plain CSS variables

    :root {
      --brand-50: #f0f5ff;
      --brand-500: #447dff;
      --brand-600: #1f5eff;
      --brand-900: #16398f;
    }
    .button { background: var(--brand-600); color: #fff; }

    HEX output works in any build setup and every browser, with no Tailwind required.

  • Accessible button colour from the scale

    brand-500 with white text   3.7:1   large text only
    brand-600 with white text   5.1:1   passes AA
    brand-700 with white text   6.8:1   passes AA

    These are the ratios for the #1F5EFF scale; yours depend on your hue. Step down the scale until white text passes 4.5:1, then use the lighter steps for backgrounds.

HEX, RGB, HSL, OKLCH and CMYK in one place

HEX and RGB describe the same thing: the red, green and blue intensities of an sRGB colour, from 0 to 255, written as hexadecimal pairs or decimal numbers. HSL rearranges those values into hue, saturation and lightness, which is easier to reason about when you want a lighter or less saturated version of a colour. CMYK expresses a colour as cyan, magenta, yellow and black ink percentages for print.

OKLCH is the newest of the five in everyday CSS. It is part of CSS Color Level 4 and is supported in all current major browsers. It describes a colour by perceived lightness (L), chroma (C, roughly colourfulness) and hue (H), in the OKLab colour space designed by Björn Ottosson so that equal steps look like equal changes to the human eye.

The converter accepts any of these formats, in modern space-separated syntax or the older comma syntax, and shows all five at once. Alpha values are accepted and ignored, because the conversions are about the colour itself.

Why OKLCH beats HSL for palettes

HSL lightness is not perceptual. hsl(60 100% 50%), a yellow, looks far brighter than hsl(240 100% 50%), a blue, even though both say 50% lightness. Rotate the hue in HSL to build a palette and the results jump around in brightness, which is why HSL palettes often need hand-tuning and why text contrast changes unpredictably across hues.

In OKLCH, colours with the same L look equally light, so you can rotate hue and keep contrast steady, and lighten or darken a colour without its hue drifting toward purple or grey as it does in HSL. That is why this tool builds every harmony, tint, shade and scale in OKLCH. Some OKLCH colours lie outside the sRGB gamut that most screens show; when that happens the tool lowers chroma, keeping lightness and hue, until the colour fits.

Harmonies, tints and shades

Colour harmonies are hue relationships from the colour wheel. Complementary uses the opposite hue (180°) for maximum contrast; analogous uses neighbours 30° either side for a calm, related palette; triadic uses three hues 120° apart; split-complementary uses the two hues next to the complement; tetradic uses four hues 90° apart. They are starting points, not rules: most interfaces use one brand hue, neutrals and one or two accents.

Tints move a colour toward white and shades toward black. Here they are calculated in OKLCH so that each step is a similar visual jump, and chroma tapers off at the extremes the way real paint and printed colour do, which avoids the chalky pastels and muddy darks of simple mixing.

A Tailwind-style 50 to 950 scale

Design systems typically need 10 or 11 steps of each colour: very light backgrounds at 50 and 100, borders at 200 and 300, the main brand colour around 500 or 600, and dark text and surfaces at 800 to 950. Tailwind CSS popularised the 50 to 950 naming, and since version 4 its default palette is defined in OKLCH.

The generator follows the lightness curve and chroma profile of Tailwind's default scales at your colour's hue. Your exact colour is kept unchanged at the step whose lightness is closest, marked with a dot, and the other steps are built around it. Export it as a Tailwind v4 @theme block (which creates utilities such as bg-brand-500), as plain CSS custom properties in HEX, or as JSON for design token tools. Our design system explainer covers how teams organise these tokens, and Tailwind vs Bootstrap compares the frameworks.

Contrast and accessibility

A colour is only useful if text on it, or the colour as text, is readable. For every base colour the tool shows the WCAG 2 contrast ratio against white and black and which one reads better. 4.5:1 is the AA minimum for body text and 3:1 for large text and interface components such as icons and input borders.

Many brand colours land in the awkward middle, where neither white nor black text passes AA. The usual fix is to use a darker step from the scale, often 600 or 700, for buttons with white text. For any specific pair, the colour contrast checker calculates the exact ratio and suggests the nearest passing shade; our web accessibility guide explains the wider requirements.

A note on CMYK and print

The CMYK values here use the standard device-independent formula: convenient for a quick reference, but not what a printer will produce. Real print conversion depends on the paper, the press and an ICC colour profile, and many bright screen colours, especially saturated blues and greens, cannot be printed at all. For anything going to press, convert in a design tool with the profile your printer specifies and ask for a proof.

From palette to colour tokens

Raw scales are the first layer of a colour system. Most teams then add semantic tokens on top, such as --color-surface, --color-text-muted, --color-accent and --color-danger, which point at steps of the scale. Components use only the semantic names, so a rebrand or a dark theme means changing which step each token points to, not editing every component.

Dark mode is the clearest example. In a light theme the surface might be brand-50 and body text brand-950; in a dark theme they swap toward brand-950 and brand-50, with accents moving a step or two lighter so they keep enough contrast on a dark background. Because the scale is perceptually even, mirrored steps behave predictably, which is much harder with hand-picked HEX values.

Keep the exported variables in one file, document what each semantic token is for, and check every text and background pairing with a contrast tool before shipping. Our UI/UX design team sets up colour tokens like this at the start of a product so design files and code use the same names.

Questions, answered

Something else on your mind? Ask a consultant and get a reply within one business day.

How do I convert HEX to RGB?

Split the six hex digits into three pairs and convert each from base 16 to decimal: #1F5EFF is 1F=31, 5E=94, FF=255, so rgb(31 94 255). Paste any HEX value above to see it instantly.

What is OKLCH?

A CSS colour format that describes colours by perceived lightness, chroma and hue in the OKLab space. Equal changes look equal to the eye, which makes palettes and contrast far more predictable than with HSL.

Can I use OKLCH in CSS today?

Yes. oklch() is part of CSS Color Level 4 and works in all current major browsers. Keep a HEX fallback only if you must support very old browsers.

Why do some OKLCH colours change when converted to HEX?

Some OKLCH colours are outside the sRGB gamut that HEX can express. The tool reduces chroma, keeping lightness and hue, until the colour fits.

How is the 50-950 scale generated?

From Tailwind's default lightness curve and chroma profile at your colour's hue, in OKLCH. Your colour stays unchanged at the closest step, marked with a dot.

Is the CMYK value print-accurate?

No. It is the standard formula without a colour profile. For print, convert in a design tool using your printer's ICC profile and request a proof.

What is the difference between HSL and OKLCH?

HSL lightness is not perceptual, so yellow and blue at 50% look very different. OKLCH lightness matches what people see, so colours at the same L have similar brightness.

Which harmony should I use for a website?

Usually one brand hue plus neutrals, with an analogous or complementary accent for calls to action. Treat harmonies as a starting point and check contrast for every text pair.

Does it support transparency?

Alpha values in 8-digit HEX, rgba() or hsla() are accepted but ignored, because the conversions and palettes are about the colour itself.

Is anything sent to a server?

No. All conversions run in your browser.

More free tools.

All tools

Need tooling like this inside your product?

We build internal tools, developer platforms and APIs. Tell us what your team keeps doing by hand.