OKLCH Colour Palette Generator
Operator: Abdulla Al Fahad. How tools are built and checked
Evenly spaced colour steps are hard to get from HSL, where a yellow and a blue at the same lightness differ wildly in brightness. Working in OKLCH makes the steps of a scale look evenly spaced to the eye. Tailwind's blue-500, #3b82f6, has an OKLCH lightness of 62.3 percent, a chroma of 0.188 and a hue of 259.8 degrees. Feed it in here and step 500 of the generated scale is exactly that hex, with 400 at #6ca4ff and 600 at #246bdd falling at the lightness the 50 to 950 ladder expects.
Harmonies rotate the hue in the same space, then each swatch is pulled back into sRGB by lowering chroma while lightness and hue are kept, so a vivid orange partner for a blue base is dulled rather than turned into a different colour.
Contrast gets as much attention as hue: the table checks every pair of swatches, white and black included, and the scale lists its ratio on white and on black for each step, so a fill colour can be chosen with its text colour already known.
Key features
- Base colour from a picker or text: #rgb, #rrggbb, rgb() or oklch()
- Six rules: complementary, split-complementary, analogous, triadic, tetradic (rectangle) and monochrome
- An 11-step scale, 50 to 950, anchored so the step nearest the base lightness is the base colour itself
- Contrast ratios on white and black for every scale step, and a pairwise matrix for the swatches with white and black
- Export to CSS variables, a Tailwind v3 config, a Tailwind v4 @theme block in OKLCH, SCSS (with a map), JSON, a GIMP .gpl palette and an Adobe .ase swatch file
Harmonies in OKLCH, the 50 to 950 ladder and the file formats
Colour input accepts three or six hex digits, rgb(59 130 246) or rgb(59, 130, 246), and oklch(62.3% 0.188 259.8) with the lightness as a percentage or a fraction. Anything else is refused with the palette left on the last readable colour. Conversion goes sRGB to linear light to OKLab to OKLCH using Björn Ottosson's matrices, and back the same way.
The scale uses fixed lightness targets of 0.975, 0.945, 0.895, 0.82, 0.72, 0.63, 0.55, 0.48, 0.41, 0.35 and 0.27 for steps 50 to 950, which sit within about 0.03 of Tailwind's own default palettes. Chroma follows a curve from 10 percent of the peak at step 50, 100 percent at 500 and 600, down to 52 percent at 950, and each step is capped at the largest chroma sRGB can show at that lightness and hue. A dark, muted or pale base lands on whichever step has the nearest lightness, so a base at 0.30 becomes step 950 instead of being forced to 500.
Contrast is the WCAG 2 ratio (L1 + 0.05) / (L2 + 0.05) on sRGB relative luminance. Grades are 3 for large text (AA large), 4.5 for AA and 7 for AAA, applied to the exact ratio and displayed cut, not rounded, to two decimals, so 4.499 shows as 4.49 and is a failure. The .ase file stores each colour as the model RGB with three 32-bit floats from 0 to 1, a UTF-16 name and the normal colour type. Its size depends on the swatch names: a 12-byte header, then 2n + 28 bytes for each colour whose name has n characters, so two swatches named brand-1 and brand-2 make a 96-byte file and two named brand make 88.
How it works
Gamut mapping binary-searches chroma between 0 and 0.4 for the largest value whose linear RGB stays within 0 to 1 at the given lightness and hue (24 halvings, finer than any 8-bit step). A swatch that fits is left alone. Monochrome uses five fixed lightness levels from 0.92 to 0.30 at the base hue, each with the base chroma limited to what that level allows. Files are text assembled from the same swatch and scale objects, so every format agrees: CSS variables are named --name-1 for swatches and --name-500 for scale steps, Tailwind v3 gets a nested name object plus flat swatch keys, v4 gets --color-name-500 in oklch(), and the SCSS file adds a map of the scale. The .ase file is written byte by byte: ASEF, version 1.0, a block count, and one entry per colour.
Typical uses
- A start-up has only a logo hex, #10b981. Entering it gives lightness 69.6 percent, so it lands on step 400, and a Tailwind v4 @theme block with --color-brand-50 to --color-brand-950 drops straight into the project's CSS.
- A designer checking a triadic scheme from #3b82f6 sees in the contrast matrix that the red #e24956 and green #3ba01b score 3.94 and 3.37 against white, both AA large only, so neither can carry body copy without a darker step from its own scale.
Building one
- Enter the brand colour in the hex box or pick it, then choose a harmony; the swatches update at once.
- Press Build a scale from this under any swatch, and read the W and K contrast figures under each step.
- Pick a format and a name, choose whether to include swatches, the scale or both, then download or copy.
Example
Base #3b82f6, analogous harmony, name brand
oklch(62.3% 0.188 259.8)
harmony: analogous (-30°, 0°, +30°)Swatches and scale
analogous: #0094c3, #3b82f6, #886cee
scale: 50 #f2f7ff, 100 #e3eeff, 200 #c9deff, 300 #a2c6ff, 400 #6ca4ff, 500 #3b82f6 (base), 600 #246bdd, 700 #1657bd, 800 #0d449a, 900 #09367b, 950 #042355
CSS: --brand-1: #0094c3; ... --brand-500: #3b82f6;Things to check before you rely on it
OKLCH covers more colours than sRGB, so a base typed as oklch() with a chroma beyond sRGB is quietly reduced to the nearest in-gamut chroma, and its hex will not match the chroma you typed.
A WCAG 2 ratio is computed from luminance alone, so it ignores font weight and size beyond the single split between 3 for large text and 4.5 for body text. A pair that scores 4.6 can still be tiring in a thin 12 px font, so check real text in the real font as well as the number.
Rotating the hue does not make colours easy to tell apart. Two swatches of the same lightness and chroma, such as a red and a green from a triadic scheme, can look alike to someone with red-green colour blindness; separate things that must be distinguished by lightness, which the scale gives you, not by hue alone.
- Read the W figure before putting white text on the base itself: #3b82f6 scores only 3.67 on white, so button labels on step 500 pass AA large but not AA, and step 600 (4.97 on white) is the safer button fill.
- A monochrome palette keeps the base hue only, so for greys with a slight tint, set a base with chroma around 0.01 to 0.03 and the five steps keep that undertone.
Common errors and how to fix them
- Typing a colour changes nothing
- The text could not be read, so the palette stays on the last colour that parsed. Use #3b82f6, rgb(59 130 246) or oklch(62.3% 0.188 259.8); colour names such as blue are not accepted.
- The oklch() colours in the Tailwind v4 file show as missing or plain
- oklch() needs Chrome 111, Safari 15.4 or Firefox 113 or newer. For an older browser, or a tool that does not read oklch(), export the CSS variables or the Tailwind v3 file, which are in hex.
- The Adobe file opens with the wrong colours in an older program
- The file stores RGB floats. A program or document that works in CMYK converts them on import, which shifts saturated colours; switch the document to RGB first.
Best practices
- Export the Tailwind v4 block when your project already writes its colours as oklch(); the hex file loses the extra precision that makes the steps line up.
Which export to use
All seven formats carry the same colours, so the choice is about where they are going.
- CSS variables: any web project; names are --name-1 for swatches and --name-500 for scale steps.
- Tailwind v3 config: a tailwind.config.js colors entry in hex, with the scale nested under the palette name.
- Tailwind v4 @theme: --color-name-500 in oklch(), for a CSS-first Tailwind v4 setup.
- SCSS: variables plus a map of the scale to loop over.
- JSON: swatches with hex, RGB and OKLCH, for design-token pipelines and scripts.
- GIMP .gpl: drop it into GIMP's palettes folder.
- Adobe .ase: load it in the Swatches panel of Adobe applications; the colours are RGB.
Frequently asked questions
Why is the partner of a blue base a dull orange-brown?
Hues are rotated at constant OKLCH lightness and chroma, then reduced in chroma to fit sRGB. At 62 percent lightness the most saturated orange sRGB can show is #b07c00, much duller than the blue, so the partner looks muddy; raise the lightness of the base and the partner brightens with it.