Light to Dark Theme Converter
Paste your CSS variables or JSON theme and instantly get dark-mode colors that preserve hue, maintain WCAG contrast, and follow semantic roles — with live side-by-side UI preview.
What Is a Light to Dark Theme Converter?
A Light to Dark Theme Converter is a tool that takes an existing light-mode theme — defined as CSS variables, JSON tokens, or a design system palette — and automatically generates an equivalent dark-mode palette that maintains the same visual identity while inverting lightness and preserving hue relationships.
This sounds simple — "just invert the colors" — but it's actually one of the hardest problems in UI design. Naive inversion (light #FFFFFF becomes dark #000000, light #F0F0F0 becomes dark #0F0F0F) produces a theme that feels cold, flat, and disconnected from the original brand. Real dark modes need to:
- Preserve hue — a light blue background should become a dark blue, not a dark grey
- Maintain contrast — text-background pairs must still pass WCAG AA in dark mode
- Reduce saturation — dark colors are perceptually more saturated than light colors, so they need desaturating
- Keep semantic meaning — "primary" stays primary, "error" stays error, "surface" stays surface
- Avoid pure black — #000000 is harsh; professional dark themes use #121212, #0F172A, or #1A1A1A
This tool solves all of these problems. You paste your existing light theme (in any of three formats), pick a conversion strategy, and get a complete dark theme with live preview, contrast checks, and copy-ready output.
Four Dark Mode Strategies (and When to Use Each)
The tool offers four different conversion strategies, each producing a noticeably different dark theme. Understanding the trade-offs helps you pick the right one for your project:
🎨 Preserve Hue (Recommended)
Keeps hue and saturation the same, inverts only the lightness (100% becomes 10%, 90% becomes 20%, etc.). Dark colors get lightened, light colors get darkened. Best for most themes — maintains brand identity.
🌫️ Soft Invert
Gentler than true invert. Light backgrounds become dark neutral (not pure black), dark text becomes light grey (not pure white). Reduces overall contrast for a softer, more comfortable dark mode. Best for reading-heavy apps.
🔄 True Invert
Pure mathematical inversion: L_dark = 100 - L_light. Preserves hue exactly but produces very high contrast — sometimes uncomfortably so. Best for demo/preview tools and accessibility-calculated palettes.
🔵 Material 3 (Google)
Google's official Material Design 3 dark palette algorithm. Backgrounds become #121212-based, surfaces step up in lightness, text is #E0E0E0, primaries become lighter versions of the light-mode primary. Best for Android and Material-first UIs.
For most modern web apps (React, Vue, Next.js), Preserve Hue or Soft Invert produces the best results. Material 3 is best when you're building a Material-based product. True Invert is educational but rarely ships to production.
Understanding Semantic Color Roles
The tool automatically detects the "role" of each variable by looking at its name. This is how it applies different conversion rules to backgrounds vs. text vs. borders. The roles it recognizes:
| Role | Detected From | Dark Mode Rule |
|---|---|---|
| Background | bg-, background, surface, card | Become dark greys/blacks — 5–20% lightness |
| Text | text-, fg-, foreground, content | Become light greys/whites — 80–98% lightness |
| Border | border, divider, ring, outline | Mid-dark greys — 25–40% lightness |
| Primary | primary, brand, accent | Slightly lighter version (dark bg needs brighter accents) |
| Success | success, green, positive | Lighter green with reduced saturation |
| Warning | warning, yellow, amber | Lighter amber with reduced saturation |
| Error | error, danger, red, destructive | Lighter red with reduced saturation |
| Info | info, blue, link | Lighter blue with reduced saturation |
Role-aware conversion is what separates a professional dark theme from a naive inversion. A "success" green in light mode is a saturated #16A34A — in dark mode it becomes a slightly desaturated, slightly lighter green so it doesn't overwhelm the dark surface. Same semantic meaning, different physics.
You can override the role of any variable by editing the role dropdown in the table (coming in future versions). For now, the tool uses name-based detection which is correct 95% of the time with well-named variables.
Why Dark Mode Contrast Is Different
WCAG contrast ratios are computed the same way in dark mode as in light mode — but human perception of contrast is not symmetric between the two. Pure white text on pure black background (21:1) is technically the highest possible contrast, but it's also the most uncomfortable to read — it causes halation, eye strain, and afterimages.
The sweet spot for dark mode body text is:
- Background: #121212 to #1A1A1A (dark grey, not pure black)
- Body text: #E0E0E0 to #F5F5F5 (not pure white)
- Secondary text: #A0A0A0 to #C0C0C0
- Contrast ratio: ~12–15:1 for body, ~7–10:1 for secondary
Notice: the highest contrast (21:1, white on black) is deliberately avoided. Material Design 3 documentation explicitly recommends against pure black backgrounds for the same reason. This tool applies these constraints automatically — the "Preserve Hue" strategy caps dark backgrounds at ~10% lightness and light text at ~92% lightness.
Dark Mode Design Best Practices
- Never use pure black (#000000) as background. Use #121212, #0F172A, or #1A1A1A. Pure black causes halation and eye strain.
- Never use pure white (#FFFFFF) as text. Use #E0E0E0 or #F0F0F0. White on black causes afterimage and shimmer.
- Reduce saturation by 20–40%. Colors look more saturated on dark backgrounds. A light-mode #16A34A green becomes a dark-mode #22C55E (lighter + less saturated).
- Elevation = lighter surface. In light mode, elevated surfaces are darker (shadow). In dark mode, elevated surfaces are lighter (illuminated). Material 3 uses +5% lightness per elevation level.
- Borders become more important. Shadows are invisible on dark backgrounds, so use 1px borders in a lighter grey to define component edges.
- Test every state. Hover, focus, active, disabled — all need dark-mode equivalents. A dark theme that only converts the base state is a broken theme.
- Provide a system preference default. Use
@media (prefers-color-scheme: dark)to respect the OS setting, but always allow manual toggle.
Who Uses a Dark Theme Converter?
🚀 SaaS Launch
You built a light theme but forgot dark mode. Convert all CSS variables in one click and ship dark mode overnight.
🎨 Design System
Convert your full token set (colors, surfaces, borders, states) to produce a parallel dark theme in your token JSON.
📱 Mobile App
iOS and Android both expect a dark theme. Generate it from your existing light palette without redesigning from scratch.
🌐 Tailwind Migration
Convert your tailwind.config.js color palette to a dark variant and wire it into darkMode: 'class'.
📚 Documentation Site
Developer docs are read at night. A proper dark theme increases readability and reduces eye strain for your readers.
🛍️ E-commerce
Shoppers browsing at night prefer dark mode. Convert your product page palette to increase browsing time and conversion.
Light to Dark Theme Converter FAQ
What is a Light to Dark Theme Converter?
A tool that takes an existing light-mode theme (CSS variables, JSON tokens, or manual color list) and automatically generates a dark-mode equivalent that preserves hue, maintains WCAG contrast, and follows semantic roles.
What input formats are supported?
Three: CSS variables (--bg-primary: #ffffff;), JSON ({"bg": {"primary": "#ffffff"}}), and manual color lists. The tool auto-detects the format.
What are the four conversion strategies?
Preserve Hue — keeps hue, inverts lightness (recommended). Soft Invert — gentler darkening for softer contrast. True Invert — mathematical inversion. Material 3 — Google's official dark palette algorithm.
Why not just invert all colors?
Naive inversion produces harsh, uncomfortable themes. Colors on dark backgrounds look more saturated (needing desaturation), pure black/white cause eye strain (needing soft greys), and semantic meaning must be preserved. A good dark theme is a reinterpretation, not an inversion.
How does the tool detect semantic roles?
By parsing the variable name. Variables named bg-* are treated as backgrounds, text-* as text, border-* as borders, success-*/error-*/warning-* as states. This works with 95% of well-named design systems.
Does the converted dark theme pass WCAG?
Yes. Every text-on-background pair in the converted theme is checked against WCAG AA (4.5:1) and AAA (7:1). The contrast column in the results table shows the actual ratio and pass/fail for each pair.
Why does the tool avoid pure black (#000000) backgrounds?
Pure black with pure white text creates the highest possible contrast (21:1), but also causes halation, afterimages, and eye strain. Material Design 3 and most professional dark themes use #121212 to #1A1A1A instead. This tool follows that convention.
Can I override specific colors after conversion?
Yes. Each variable in the results table has a clickable swatch that opens a color picker. Changes update the preview and output in real time.
What output formats are available?
Three: CSS variables (paste into :root or [data-theme="dark"]), JSON (for design tools like Figma Tokens or Style Dictionary), and Tailwind config (for tailwind.config.js).
How many variables can I convert at once?
The tool handles up to 100 variables per conversion. Most design systems have 30–80 tokens, so this is more than enough.
Does the tool work with shadcn/ui?
Yes — this is one of the intended use cases. Paste your shadcn/ui light theme CSS variables, click Convert, and get the dark theme. The tool is pre-loaded with a shadcn/ui sample for quick testing.
Does the tool work with Tailwind CSS?
Yes. You can paste Tailwind's default color palette or your custom tailwind.config.js colors, and the tool converts them to a dark theme. It also outputs a Tailwind config snippet ready to paste back.
Is the conversion reversible?
Not automatically — but the dark theme output can be re-converted to light by running it through the tool again with the "Preserve Hue" strategy. The result won't be identical to your original, but it will be functionally equivalent.
Does this tool store my theme?
No. Everything runs locally in your browser. No data is uploaded, stored, or shared. Your theme is processed in memory and discarded when you close the tab.
Is the tool free?
Yes. Completely free, no signup, no email, no data collection. You can use it as many times as you like for unlimited projects.