Tailwind Theme to CSS Variables
Transpile a Tailwind v3 theme into CSS custom properties
Tailwind config
12 lines · 289 charsCSS variables
11 variables:root {
--color-primary: #2563eb;
--color-primary-500: #2563eb;
--color-primary-500-rgb: 37 99 235;
--color-primary-700: #1d4ed8;
--color-primary-700-rgb: 29 78 216;
--color-primary-rgb: 37 99 235;
--color-surface: #ffffff;
--color-surface-rgb: 255 255 255;
--font-family-sans: Inter, "Segoe UI", sans-serif;
--spacing-4: 1rem;
--spacing-8: 2rem;
}Examples
Nested palette plus spacing and fonts
{ theme: { extend: { spacing: { 4: '1rem' }, color: { primary: { 500: '#336699' } }, fontFamily: { sans: ['Inter', 'sans-serif'] } } } }--color-primary-500: #336699; --spacing-4: 1rem; --font-family-sans: Inter, sans-serif;Each section walks to its kind prefix with kebab-case paths; arrays join font stacks with commas.
Alpha-ready brand color
{ colors: { brand: '#0f172a/<alpha-value>' } }--color-brand-rgb: 15 23 42; --color-brand: rgb(var(--color-brand-rgb) / <alpha-value>);The hex converts to an RGB triplet and the variable rewrites through var() so opacity modifiers apply.
About this tool
Tailwind to CSS Variables transpiles a theme config with transpileTailwindConfig(input): a comment-stripping LiteralParser (/* */ and // removed first) accepts object literals, module.exports assignment, quoted and bare keys, strings, numbers, booleans, and arrays — then walks the colors/color (kind color), fontFamily (kind font-family), and spacing sections, whether nested under theme.extend or at the root. Empty input returns a Paste-a-Tailwind error; unparseable text returns error with empty css.
Walking is deterministic: object keys sort alphabetically, nested color trees flatten to kebab-case paths (--color-primary-light-default), fontFamily arrays join with , (--font-family-sans: Inter, sans-serif), and spacing scalars emit --spacing-* — every variable sorts by name into a :root block. Nullish values warn as skipped, and function-valued entries (function keyword or => arrows) are never evaluated: the sentinel path records Skipped function value at colors.dynamic. and the variable is omitted.
Opacity-ready colors get first-class treatment: any color whose value contains <alpha-value> also emits a --color-<path>-rgb triplet derived from the hex (e.g. #0f172a → 15 23 42), and the main variable rewrites to rgb(var(--color-<path>-rgb) / <alpha-value>). Non-hex colors pass through verbatim with no rgb helper.
How to use this tool
Paste the theme object
Supply the config literal (comments allowed) with colors/color, fontFamily, or spacing — under theme.extend or at the root — and read css plus sorted variables.
Flatten nested palettes
Nest shades freely (primary: { 500, light: { DEFAULT } }); each leaf becomes --color-<kebab-path> in sorted order.
Keep opacity modifiers working
Write hex colors as #0f172a/<alpha-value> to get the -rgb triplet plus the rgb(var(...-rgb) / <alpha-value>) rewrite.
Heed the warnings
Function values are skipped with a Skipped function value warning — replace dynamic entries with literals before emitting.
Use cases
Bridging Tailwind tokens to vanilla CSS
Export --color-*, --spacing-*, and --font-family-* variables for non-Tailwind stylesheets or component libraries.
Auditing dynamic theme values
Find function-valued entries via warnings and replace them with static literals the transpiler can emit.
Shipping opacity-compatible palettes
Generate -rgb triplets alongside <alpha-value> colors so bg-brand/50 style modifiers resolve at runtime.
Common mistakes
Mistake:Putting executable functions in the pasted config.
Fix:Arrow functions and function keywords are never evaluated — they warn and skip. Paste plain literals only.
Mistake:Expecting every section of the config to be emitted.
Fix:Only colors/color, fontFamily, and spacing walk; other keys are ignored, and empty results still render :root {}.
Mistake:Writing <alpha-value> on a non-hex color.
Fix:The -rgb helper derives from #rrggbb hex only; named or rgb() colors pass through with no triplet.
Frequently asked questions
What does this tool do?
It transpiles a Tailwind theme literal with transpileTailwindConfig into sorted :root CSS variables: colors/color → --color-*, fontFamily → --font-family-*, spacing → --spacing-*, from theme.extend or the root object, with comment stripping and literal-only parsing.
How do nested colors, fonts, spacing, alpha helpers, and comments behave?
primary: { 500, light: { DEFAULT } } flattens to --color-primary-*-* kebab paths; sans: ['Inter','sans-serif'] joins with commas; spacing scalars emit --spacing-*; #0f172a/<alpha-value> adds --color-brand-rgb: 15 23 42 plus an rgb(var()) rewrite; and // plus /* */ comments are stripped before parsing.
Is my config uploaded or stored?
No. Comment stripping, literal parsing, tree walking, and CSS emission run entirely in your browser — configs never leave your device.
Why is a value missing from the output?
Function values (=> or function) are never evaluated — they warn Skipped function value at colors.dynamic. and are omitted. Replace them with literals; malformed input instead returns error with empty css.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.