Color palette generator

Press Generate (or the Space bar) for a new palette. Lock the colors you like, pick a harmony such as triadic or complementary, and copy the result as code.

Press Space to generate and Ctrl/Cmd+Z to undo (add Shift to redo) when focus is not in a text field or on a button. Harmony modes build on the first locked color, or on a random color if none is locked.

    Export
    
      

    How to use the color palette generator

    1. Choose a Mode. Random gives a varied palette; the harmony modes place colors at set hue angles from a base color.
    2. Press Generate or the Space bar until you see a palette you like. Use Add color and the × button on a swatch to get between 2 and 10 colors.
    3. Click Lock on any color to keep it through the next generation. In harmony modes the first locked color becomes the base.
    4. Fine-tune a swatch by typing a color (HEX, rgb(), hsl(), oklch() or a CSS name) and pressing Enter, or with its color picker. Use the arrow buttons to reorder.
    5. Tick Show RGB, HSL, OKLCH and nearest CSS color name for each color's values and nearest CSS name. Use Undo and Redo to step back through recent palettes.
    6. Pick an export format, set a variable prefix, and click Copy. Copy link shares the palette, its locks and mode.

    What it does

    The generator builds palettes of 2 to 10 colors. Every calculation runs in your browser in the OKLCH color space, where lightness and hue are closer to how the eye judges them than in HSL. Each swatch shows its HEX value in black or white text, whichever has the higher WCAG contrast against it, so the label stays readable. The current palette, locks and mode are kept in the page address, so the link reopens the same palette, and your last palette and settings are saved in this browser's local storage.

    How each mode works

    Harmony modes take a base color, read its OKLCH hue, and add fixed angles to it. The base is the first locked color, or a random mid-lightness color when nothing is locked. If a mode has fewer anchor hues than the palette has colors, it repeats the anchors as lighter and darker variants.

    ModeHues relative to the baseCharacter
    RandomSteps of 20° to 70° from the previous hueLightness spread from dark to light in random order, softer chroma near black and white
    AnalogousWithin 30° either side of the base: −30°, +30°, then −15°, +15°Neighbors on the wheel; calm and low-contrast in hue
    Complementary0° and 180°Opposite hues; strongest hue contrast
    Split complementary0°, 150° and 210°The two neighbors of the complement; contrast with less tension
    Triadic0°, 120° and 240°Three hues evenly spaced
    Tetradic0°, 90°, 180° and 270°A square of four hues: two complementary pairs
    Monochromatic0° onlyOne hue at varied lightness and chroma
    Shades of one hue0° onlyOne hue ordered from light to dark, chroma tapering at the ends

    The harmony colors keep the base's lightness and chroma, with a small random nudge to lightness so repeated generations differ. Some hues cannot reach the same chroma inside sRGB at that lightness. Those colors are gamut mapped the CSS Color 4 way: chroma is lowered until the color fits, and the final clip can move the hue by a few degrees.

    Worked example

    Lock #4F46E5 and choose Triadic. Its OKLCH value is oklch(51.06% 0.2301 276.97), so the triad hues are 276.97 + 120 = 36.97° and 276.97 + 240 = 156.97° (wrapped past 360).

    The label on #4F46E5 is white because white text scores 6.29:1 against it and black only 3.34:1. Exported with the prefix brand, a CSS block starts :root { --brand-1: #4f46e5; … and the Tailwind v4 block starts @theme { --color-brand-1: #4f46e5; …, which gives you utilities such as bg-brand-1.

    Export formats

    FormatOutput
    CSS variables:root { --color-1: #4f46e5; }
    Tailwind v4@theme { --color-palette-1: #4f46e5; }. Tailwind theme colors must use the --color- namespace, so the default prefix becomes palette here, and a prefix such as brand gives --color-brand-1.
    SCSS$color-1: #4f46e5;
    JSON["#4f46e5", …]
    HEX list#4f46e5, #f59e0b

    Common mistakes

    Key terms

    OKLCH
    A CSS color format of lightness, chroma and hue, built on the OKLab color space published by Björn Ottosson in 2020. Equal steps in its lightness look roughly equal to the eye, which plain HSL does not manage. Tailwind CSS v4 defines its default palette in OKLCH.
    Color harmony
    How well colors work together; color-wheel schemes such as complementary (180°) or triadic (120°) are common rules for it.
    Complementary colors
    Two hues on opposite sides of the color wheel, 180° apart. They are traditionally seen as the strongest hue contrast, and are often used for an accent against a main color. Which hue counts as opposite depends on the color wheel used.
    Analogous colors
    Hues that sit next to each other on the color wheel, typically within about 30° either side of a base. They look related and calm.
    Triadic colors
    Three hues spaced evenly around the color wheel, 120° apart, giving a balanced but lively set.
    Gamut mapping
    Turning a color that is outside a gamut into the closest color inside it. CSS Color 4's gamut mapping algorithm keeps lightness and hue and lowering chroma until the result is within a just-noticeable difference of a color the screen can show; the final clip can shift the hue slightly.

    Frequently asked questions

    How do I keep a color I like?
    Click Lock on its swatch. Locked colors keep their value and position when you generate again, and the first locked color is the base for harmony modes.
    Why use OKLCH instead of HSL for harmonies?
    OKLCH hue and lightness track human perception more closely, so colors at the same OKLCH lightness look about equally light. In HSL, yellow and blue at the same lightness value look very different.
    Can I share a palette?
    Yes. The page address stores the colors, which ones are locked, and the mode, for example ?colors=4f46e5-f59e0b&locked=0&mode=triadic. Copy link copies it.
    What does the Space bar do?
    It generates a new palette when focus is not in a text field or on a button, so it does not interfere with typing or with pressing buttons from the keyboard.
    How many palettes can I undo?
    Undo and Redo keep the last 20 palettes in this tab (19 steps back), including generations, edits and reordering. The history is cleared when you reload the page.
    How is the swatch text color chosen?
    The tool works out the WCAG contrast ratio of black and of white against the swatch and uses whichever is higher.
    How do I use the Tailwind export?
    Paste the @theme block into your main CSS file after importing Tailwind CSS v4. Each variable becomes a color, so --color-brand-1 is available as bg-brand-1, text-brand-1 and so on.

    Sources: CSS Color Module Level 4 (W3C), A perceptual color space for image processing (Björn Ottosson), Tailwind CSS: theme variables, WCAG 2.2 contrast ratio. Last checked 2026-11-17.