Type a tool name, for example "keyword density" or "transcript".
Generate a dark mode CSS override for your website by inverting and adjusting your existing color palette.
This dark mode CSS generator turns the nine colors of your light theme into a ready-to-paste dark theme. You enter hex values for backgrounds, text, borders, accent, links, cards and header, choose a media query, a class toggle or both, and copy the generated CSS. It is free and needs no sign-in.
Dark mode CSS is a set of style rules that replaces light page colors with dark ones while keeping text readable. Most developers do not write a second stylesheet. They define each color once as a CSS custom property, then redefine those values for the dark theme so every element updates at the same time.
A page can switch to the dark values in two common ways, and the tool supports both.
The @media (prefers-color-scheme: dark) query applies your dark values when the visitor's operating system or browser is set to dark. You need no script and no button. The trade-off is that visitors cannot override their system setting on your site.
With this method, the dark values apply whenever a .dark class sits on the page's root element. You add a small script and a button that adds or removes the class. Visitors can then pick a theme no matter what their system uses.
The Both methods option covers automatic detection and manual switching in a single output. It suits sites that want to respect the system setting by default and still offer a theme button.
You can go from palette to finished CSS in a few steps, and each one matches a control on the page.
Changing any color after generating clears the old result, so you never copy code that does not match your inputs.
Using the default values on the page shows exactly what the generator does with a typical white, gray and blue design. Here are four of the nine results.
| Color field | Light value | Dark value |
|---|---|---|
| Background Primary | #ffffff | #1a1a2e |
| Text Primary | #111827 | #e8e8f0 |
| Card Background | #ffffff | #242438 |
| Accent / Brand | #3b82f6 | #4f96ff |
The logic is simple. A very light background becomes a deep navy, a very dark text color becomes a soft off-white, and cards sit slightly lighter than the page so they stand out. Accent and link colors are brightened rather than inverted, which keeps your blue recognizable on a dark surface.
Two results deserve a closer look. The default gray Text Secondary (#6b7280) would not reach a 4.5:1 contrast ratio on the dark surfaces after conversion, so the generator replaces it with white or black, whichever reads better, and adds a contrast note. The default Header Background (#1f2937) is already dark, so it flips to a light gray (#d4d4dc). If you want your header to stay dark, adjust it in the generated CSS.
The result is a block of CSS containing your light values as custom properties on the root, plus a dark set of the same properties. Depending on your method, the dark set sits inside a media query, under a .dark selector, or both. The properties cover background, text, border, accent, link, card and header colors.
The generator checks text colors against your three surface colors (primary background, secondary background and card background) using the 4.5:1 ratio that the Web Content Accessibility Guidelines set for normal-size text. Large text has a lower threshold of 3:1, but 4.5:1 is the safe target for body copy.
Anyone who maintains a light-only site and wants a dark option without redesigning it can start here. A few concrete situations:
If you work with Tailwind, note that this tool outputs plain CSS custom properties, not Tailwind configuration. You can still copy the dark hex values into your Tailwind theme and apply them with its dark: variants.
Dark mode fails most often in the details around the generated colors, not in the colors themselves.
var(--bg-primary) or another matching property.color-scheme: dark in your dark rules helps form controls and scrollbars match the theme.After adding dark styles, keep your stylesheet lean. You can run it through the Unused CSS Extractor to remove selectors that no page uses, and confirm your server compresses the file with the GZIP compression checker.
The generator applies fixed brightness rules to your hex values, so the output is a strong starting point rather than a finished design. It does not know your brand guidelines, and it does not restyle images, shadows, gradients or embedded content. Colors beyond the nine fields are not converted.
Accessibility notes cover text contrast only. They do not test focus outlines, button states or color-only cues. Review the finished dark theme in a real browser on a few pages before launch.
Choosing between themes has no direct ranking effect, but a readable, comfortable page supports engagement, and the extra CSS adds weight. Pair this work with a look at the code to text ratio checker and the HTTP/2 and HTTP/3 checker to keep delivery fast, or browse the Website Audit and Performance tools for more checks.
Set your nine light colors above, pick your method and click Generate Dark Mode CSS to get code you can paste into your site today.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market