| name | design-token-exporter |
| description | Exports design system tokens (colors, spacing, typography, shadows, radii) to
CSS custom properties, JavaScript/TypeScript constants, Figma tokens (W3C format),
or Tailwind config extensions. Use this skill whenever a user says "export my
design tokens", "convert these tokens to CSS variables", "generate a Tailwind
config from my tokens", "create a JS tokens file", "write design tokens for my
design system", "export tokens from Figma format", or "sync my design and code
tokens". Also activate when someone wants to centralize colors, spacing, or
typography across design and code. Do NOT use for generating the colors or
spacing values themselves (use color-palette-generator first).
|
Design Token Exporter
Convert design system tokens to any target format: CSS custom properties,
TypeScript constants, Tailwind config, or W3C/Figma Design Tokens JSON.
When to Use
- Centralizing design decisions (colors, spacing, type) across design and code
- Generating multiple output formats from a single source of truth
- Syncing Figma token changes to your CSS/JS codebase
- Onboarding a new design system with a clean token foundation
When NOT to Use
- Generating the actual color palette (use
color-palette-generator)
- Component-level styling (tokens power the system, not individual components)
- Animation tokens (timing functions, durations — see
animation-snippet-writer)
Workflow
Step 1 — Receive the Token Set
Accept tokens in any format:
- A table of names and values
- A Figma export (JSON)
- A description ("I have 4 grays, a blue primary, 8-step spacing scale")
- An existing CSS variables file to reformat
Ask: "Which output formats do you need? (CSS vars / TypeScript / Tailwind / W3C JSON / all)"
Step 2 — Organize Into Token Categories
Structure tokens into these groups:
tokens/
├── color.tokens.json — color primitives + semantic roles
├── spacing.tokens.json — space scale (4px base)
├── typography.tokens.json — font sizes, weights, line heights
├── radius.tokens.json — border radius values
├── shadow.tokens.json — box shadow values
└── index.tokens.json — re-exports all
Step 3 — Generate CSS Custom Properties
:root {
--color-blue-50: #eff6ff;
--color-blue-500: #3b82f6;
--color-blue-600: #2563eb;
--color-gray-50: #f9fafb;
--color-gray-900: #111827;
--color-brand: var(--color-blue-600);
--color-brand-hover: var(--color-blue-700);
--color-text-primary: var(--color-gray-900);
--color-surface: var(--color-gray-50);
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 0.75rem;
--space-4: 1rem;
--space-5: 1.25rem;
--space-6: 1.5rem;
--space-8: 2rem;
--space-10: 2.5rem;
--space-12: 3rem;
--space-16: 4rem;
--space-20: 5rem;
--space-24: 6rem;
--font-sans: "Inter", system-ui, -apple-system, sans-serif;
--font-mono: "Fira Code", "Cascadia Code", monospace;
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
--text-2xl: 1.5rem;
--text-3xl: 1.875rem;
--text-4xl: 2.25rem;
--font-normal: 400;
--font-medium: 500;
--font-semibold: 600;
--font-bold: 700;
--leading-tight: 1.25;
--leading-normal: 1.5;
--leading-relaxed: 1.625;
--radius-sm: 0.125rem;
--radius-md: 0.375rem;
--radius-lg: 0.5rem;
--radius-xl: 0.75rem;
--radius-2xl: 1rem;
--radius-full: 9999px;
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}
Step 4 — Generate TypeScript Constants
export const colors = {
blue: {
50: "#EFF6FF",
500: "#3B82F6",
600: "#2563EB",
},
gray: {
50: "#F9FAFB",
900: "#111827",
},
} as const;
export const semantic = {
brand: colors.blue[600],
brandHover: colors.blue[700],
textPrimary: colors.gray[900],
surface: colors.gray[50],
} as const;
export const spacing = {
1: "0.25rem",
2: "0.5rem",
4: "1rem",
8: "2rem",
16: "4rem",
} as const;
export const radius = {
sm: "0.125rem",
md: "0.375rem",
lg: "0.5rem",
full: "9999px",
} as const;
Step 5 — Generate Tailwind Config Extension
const tokens = require("./generated/tokens");
module.exports = {
theme: {
extend: {
colors: {
brand: {
DEFAULT: tokens.semantic.brand,
hover: tokens.semantic.brandHover,
},
blue: tokens.colors.blue,
},
spacing: tokens.spacing,
borderRadius: tokens.radius,
fontFamily: {
sans: ["Inter", "system-ui", "sans-serif"],
mono: ["Fira Code", "monospace"],
},
},
},
};
Step 6 — Generate W3C Design Tokens (Figma/Tokens Studio)
{
"$metadata": { "tokenSetOrder": ["global", "semantic", "component"] },
"global": {
"color": {
"blue": {
"500": { "$value": "#3B82F6", "$type": "color" },
"600": { "$value": "#2563EB", "$type": "color" }
}
},
"spacing": {
"4": { "$value": "1rem", "$type": "dimension" },
"8": { "$value": "2rem", "$type": "dimension" }
}
},
"semantic": {
"color": {
"brand": { "$value": "{global.color.blue.600}", "$type": "color" }
}
}
}
Output Format
- CSS custom properties — complete
:root block
- TypeScript constants —
as const objects for type safety
- Tailwind config extension — if applicable
- W3C Design Tokens JSON — if Figma/Tokens Studio sync is needed
Safety & Confirmation
- Mark all generated files with a "DO NOT EDIT MANUALLY" comment and a note about the source of truth.
- If tokens are referenced across CSS, JS, and Tailwind, establish one source of truth (recommend a JSON file + build step to generate others).
- Never duplicate semantic tokens — always reference primitives through semantic aliases.
- Confirm token naming convention with the team before generating (kebab-case vs. camelCase matters for search/replace).