Design Tokens to Code
Convert W3C Design Tokens (DTCG) into CSS, Tailwind, JavaScript or SwiftUI. Aliases are resolved and errors are listed.
W3C token JSON
42 lines · 686 charsGenerated code
CSS custom properties:root {
--color-link: #6750A4;
--color-primary: #6750A4; /* Brand color */
--shadow-card: 0px 2px 8px #0002;
--spacing-md: 16px;
}Examples
Alias chain resolves to the value
{ "a": { "b": { "$type": "color", "$value": "{b.c}" } }, "b": { "c": { "$type": "color", "$value": "#112233" } } }--a-b: #112233;
--b-c: #112233;a.b follows b.c to the literal, so both CSS variables carry the resolved hex with no errors.
Multi-layer shadow
{ "el": { "$type": "shadow", "$value": [{ "color": "#000", "offsetX": "0px", "offsetY": "2px", "blur": "4px" }, { "color": "#fff", "offsetX": "0px", "offsetY": "1px" }] } }0px 2px 4px #000, 0px 1px #fffEach layer joins offsetX/offsetY/blur/color with spaces and layers join with commas.
About this tool
Design Tokens to Code ingests W3C-DTCG-style JSON with formatDesignTokens(source, target) for css, tailwind, tailwind-config, and swift targets. collect walks nested groups depth-first in sorted key order, inheriting $type down the tree; a node with $value becomes a token at its dot path (e.g. color.primary) while typeless or type-unknown nodes push Missing or unsupported $type instead of throwing. Six types are accepted: color, dimension, fontFamily, fontWeight, shadow, and borderRadius.
Aliases use {path} syntax in both exact ({color.primary}) and embedded (1px solid {color.primary}) forms, with an optional $ prefix stripped before lookup. Resolution is recursive through the token map, so chains like a.b → b.c → #112233 settle to the final value, while unknown names throw Unknown alias and revisiting a path in the resolution stack throws Alias cycle: a → b → a — both reported as per-path errors with valid tokens still emitted. Resolved values are validated per type (dimension/borderRadius need {value, unit}, color needs a string or colorSpace+components, shadow needs a non-empty layer or object) or reported as Invalid <type> token value.
Emission is deterministic and per-target: css and tailwind render :root/@theme blocks with kebab-case --path-name variables, tailwind-config renders an extend map, and swift renders Color/Font extensions filtered by type with quoted-string escaping. Multi-layer shadows join layers with commas (0px 2px 4px #0003, 0px -1px #fff), font families quote whitespace-containing faces, and srgb component triples convert to hex with alpha suffixes. Malformed JSON returns a JSON-path error with empty output rather than throwing.
How to use this tool
Paste DTCG JSON
Provide nested groups with $type and $value (e.g. color.primary as color #336699). Tokens collect in sorted path order; typeless nodes report errors.
Link with aliases
Reference other tokens as {color.primary} alone or embedded in strings. Chains resolve transitively; cycles and unknown names become errors.
Pick a target
Choose css (:root variables), tailwind (@theme), tailwind-config (extend map), or swift (Color/Font extensions) and copy the output block.
Use cases
Shipping themed CSS
Export resolved --color-* and --spacing-* variables from one token file into :root or @theme blocks.
Keeping aliases honest
Catch Unknown alias and Alias cycle errors plus invalid $type values before tokens reach production.
Feeding native apps
Render the swift target to get typed Color/Font extensions alongside the web CSS from the same source.
Common mistakes
Mistake:Omitting $type on a leaf token.
Fix:Every $value node needs a supported $type (or an inherited one from its group); otherwise it reports Missing or unsupported $type and is skipped.
Mistake:Creating an alias loop.
Fix:a → b → a throws Alias cycle with the path chain. Break the loop so one token holds the literal value.
Mistake:Feeding a raw dimension string where an object is required.
Fix:dimension and borderRadius validate as {value, unit} after resolution — supply {"value": 8, "unit": "px"} rather than "8px" when the target must type-check.
Frequently asked questions
What does this tool do?
It converts W3C-DTCG-style JSON into css, tailwind, tailwind-config, or swift output with formatDesignTokens: sorted dot-path tokens in six types (color, dimension, fontFamily, fontWeight, shadow, borderRadius), recursive {path} aliases, per-type validation, and deterministic variable emission.
How do alias chains, cycles, shadows, and bad types behave?
a.b → {b.c} → #112233 resolves both variables to #112233; an x↔y loop reports Alias cycle without throwing; a two-layer shadow renders 0px 2px 4px #000, 0px 1px #fff; and $type wat reports Missing or unsupported $type as a per-path error.
Is my token file uploaded or stored?
No. Collection, alias resolution, validation, and target rendering are pure client-side string math — token files never leave your browser.
Why is a token missing from the output?
It failed validation: typeless leaves report Missing or unsupported $type, wrong shapes report Invalid <type> token value, and unresolvable aliases report Unknown alias or Alias cycle. Fix the flagged path; valid tokens still emit.
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.