Cette page n’est pas encore traduite en français : elle s’affiche en anglais.

CSS Variables to Tailwind Config Converter

Turn your :root color variables into a Tailwind theme in one paste — Tailwind v3 tailwind.config.js or v4 @theme, with literal values or var() references.

Mis à jour le
Tailwind output

Vos données ne quittent jamais votre ordinateur. Tout le traitement se fait localement dans votre navigateur.

Comment utiliser : CSS Variables to Tailwind

  1. Paste your CSS — a whole stylesheet is fine; only custom properties are read.
  2. Choose Tailwind v3 config (a module.exports colors object) or Tailwind v4 @theme.
  3. Pick Literal values to copy the colors, or var() references to keep your variables as the single source of truth (best for dark mode and theming).
  4. Copy or download the result into tailwind.config.js or your main CSS file.

What does this converter do?

Many projects start with design tokens written as CSS custom properties — --primary: #ff0055;, --brand-500: #6366f1;. When you adopt Tailwind you need the same colors in its theme so classes like bg-primary and text-brand-500 exist. Retyping them is slow and error-prone; this tool parses every custom property, keeps the ones that are colors and writes the Tailwind structure for you.

How variables are grouped

  • --brand-50 … --brand-900 become a nested brand: { 50: …, 900: … } object, giving you bg-brand-50 through bg-brand-900.
  • Suffixes like -light, -dark, -hover and -foreground are grouped under their base name; the plain variable becomes DEFAULT, so bg-primary and bg-primary-light both work.
  • A leading color- prefix is removed (--color-surface → surface).
  • Non-color tokens such as --radius-md: 8px or font stacks are skipped and listed.

Tailwind v3 vs v4

Tailwind v3 configures colors in JavaScript under theme.extend.colors. Tailwind v4 moved configuration into CSS: any --color-* variable inside an @theme block generates color utilities, and v4’s default palette uses OKLCH — which is why the v4 output converts literal values to oklch().

Literal values or var() references?

Referencing variables (primary: 'var(--primary)') means you can redefine --primary inside .dark or a brand theme and every Tailwind class follows automatically. Note that Tailwind v3 can’t apply opacity modifiers like bg-primary/50 to plain var() colors; store channels instead (--primary: 255 0 85 with rgb(var(--primary) / <alpha-value>)) if you need them. Tailwind v4 handles opacity modifiers on variables via color-mix().

Aussi recherché comme : tailwind config, css custom properties, tailwind colors, theme, @theme, design tokens, tailwind v4.

Outils complémentaires : CSS Variables to Tailwind

  • Générateur de couleurs Tailwind — Il vous suffit de coller une couleur de marque pour obtenir une palette de nuances équilibrée en 11 étapes (de 50 à 950) intégrée à OKLCH, avec des indications de contraste et des options d'exportation vers Tailwind v3, v4, CSS et SCSS.
  • Color Converter — Paste any CSS color — HEX, rgb(), hsl(), hwb(), oklch() or a name like tomato — and get every other format instantly, plus a ready-to-use 50–950 palette.
  • CSS Formatter — Turn a minified stylesheet into readable CSS with one property per line and properly nested @media blocks.
  • Color Name Finder — Paste a HEX code to get its closest human-readable name and clean token names for your CSS, SCSS, JavaScript or Tailwind config.

Questions fréquentes

Does it work with Tailwind CSS v4?
Yes. Choose “Tailwind v4 @theme” to get a CSS block with --color-* variables, which v4 turns into utilities such as bg-primary.
Which color formats are recognized?
HEX (3, 4, 6 and 8 digits), rgb()/rgba(), hsl()/hsla(), hwb(), oklch(), oklab(), CSS named colors and references to other variables like var(--blue-500).
What happens to non-color variables?
Spacing, radius, font and other non-color tokens are skipped and listed under the input so you can move them to the right part of your config manually.
Is my CSS uploaded?
No — parsing runs in your browser. Your input is only remembered in this browser’s local storage for convenience.
Puis-je installer CSS Variables to Tailwind en tant qu’application web et l’utiliser hors ligne ?
Oui. CSS Variables to Tailwind est une application web installable (PWA) : elle s’installe depuis votre navigateur, sans passer par une boutique d’applications. Cliquez sur « Installer l’application » en haut de cette page dans Chrome ou Edge (Windows, macOS, Linux, ChromeOS) ; sur Android, utilisez « Partager » → « Ajouter à l’écran d’accueil » sur iPhone et iPad ; ou « Fichier » → « Ajouter au Dock » dans Safari 17+ sur Mac. L’application s’ouvre alors dans sa propre fenêtre avec sa propre icône, et comme elle s’exécute entièrement dans votre navigateur, elle continue de fonctionner hors ligne. Firefox sur ordinateur de bureau ne permet pas d’installer d’applications web. Comment fonctionne l’installation.

Outils similaires