Skip to content

CSS Light-to-Dark Converter

Don't rely on generic color inversions that look cheap and muddy. Paste your light mode CSS variables to automatically generate a professionally balanced, low-strain dark mode theme.

Light CSS Code Input

Paste your CSS root variables stylesheet below.

Accent Desaturation 15%

Live Layout Preview

PREVIEW COMPONENT
TAG CATEGORY

Header Element Text

This preview renders the compiled color themes in real-time. Toggle light/dark modes above to compare!

Generated Dark Mode CSS

Copied code!

What the converter changes, and what it deliberately does not

What it does

Reads a light-theme CSS variable block and writes a dark-theme version of it. Near-white surfaces become dark elevated surfaces, dark text becomes light, and saturated accent colours are pulled back and re-lit so they do not glow against a dark background.

When you would use it

You already have a working light theme expressed as CSS custom properties and need a dark counterpart that keeps the same semantic roles. It is the difference between hand-picking thirty colours and reviewing thirty generated ones.

How to use it

  1. Paste your :root block. Any variable names work — the converter reads the colour values and the property names, not a fixed list.
  2. Set the accent desaturation. This is how far saturated brand colours are pulled back on the dark side; zero keeps them loud.
  3. Compare the light and dark previews of the same layout.
  4. Copy the generated CSS, then verify body text against the new surfaces in the contrast checker rather than trusting the preview alone.

Worked example — a near-white background is not inverted to black

Give the converter a #FFFFFF background, a #F8FAFC surface, #0F172A body text and a #635BFF primary. Any colour whose HSL lightness is above 0.93 is treated as a background and remapped to a dark surface instead of being inverted: pure #000000 reads as a hole on OLED, crushes shadows, and makes every elevation step invisible. The two near-white surfaces become two dark surfaces about one step apart so hierarchy survives; the near-black text becomes light; and the primary keeps its hue but loses saturation and gains lightness, because a saturated blue at full strength vibrates against a dark field. The exact output hexes depend on the desaturation setting, which is why the panel shows them rather than hiding them behind a single “convert” button.

How the calculation works

Colours are parsed into HSL. Surfaces are identified by lightness — anything above 0.93 is a background, not a fill — and mapped into a dark range with a small elevation offset between adjacent surface values. Non-surface colours keep their hue, have saturation scaled by your desaturation control, and have lightness adjusted so the role still reads: text becomes light, accents stay distinguishable from the background. Pure black and pure white are avoided at both ends because both destroy the perception of elevation.

Limitations

  • It converts CSS custom properties. Colours hard-coded inside component rules, Tailwind class names, images and shadows are outside its scope.
  • It infers roles from property names and lightness. A variable named --background that holds a bright accent colour will be treated as a surface, so review the output.
  • The preview is a layout, not your layout. Contrast that looks fine at preview scale can fail on real text sizes — check the pairs.
  • Dark mode is not a colour inversion. Photographs, illustrations, logos and charts usually need separate dark variants that this tool cannot produce.