W3C Design Tokens JSON (design-tokens.json) Explained With Examples

The W3C Design Tokens JSON format stores brand colors, font families, spacing, and radii in one tool-neutral file using standardized $value, $type, and $description keys. One design-tokens.json file feeds CSS variables, Tailwind themes, mobile apps, and AI coding agents from a single source of truth.

How the W3C DTCG token structure works

Before the W3C Design Tokens Community Group specification, every design plugin invented its own incompatible JSON keys such as value, hex, or colorCode. The W3C format prefixes metadata keys with a dollar sign ($value, $type, $description) so parsers distinguish token properties cleanly from nested group names.

Tokens are grouped hierarchically by purpose such as color.brand.primary or typography.fontFamily.heading. Placing a $type property on a token (or inheriting it from a parent group) lets build scripts validate values before compiling CSS, iOS Swift, or Android XML outputs.

Valid W3C DTCG design-tokens.json snippet

{
  "color": {
    "brand": {
      "primary": {
        "$value": "#1d4ed8",
        "$type": "color",
        "$description": "Primary action buttons and links"
      },
      "ink": {
        "$value": "#0f172a",
        "$type": "color",
        "$description": "Primary headings and body copy"
      }
    }
  },
  "spacing": {
    "local": { "$value": "4px", "$type": "dimension" },
    "group": { "$value": "16px", "$type": "dimension" },
    "section": { "$value": "64px", "$type": "dimension" }
  }
}

Semantic tokens vs. tonal scale ramps

Keep two clear layers inside design-tokens.json: semantic role tokens (primary, secondary, accent, surface, ink) and numeric tonal ramps (100 through 900) for hover borders, tinted surfaces, and dark-mode adaptations.

Components should reference semantic roles first rather than raw hex codes. When a brand shifts its primary color from cobalt to forest green, updating five semantic tokens updates every page consistently.

Core W3C DTCG $type values used in brand style guides
$typeExample $valueUsed for
color#1d4ed8Brand roles, surfaces, borders, 100-900 ramps
fontFamilyui-sans-serif, system-ui, sans-serifHeading, body, and monospace stacks
dimension1.25rem or 16pxType scale steps, spacing progression, radii
number1.55 or 600Unitless line heights and font weights

Why AI coding agents benefit from committed token JSON

When you commit design-tokens.json next to BRAND.md, automated linters and AI agents can verify every CSS declaration against a strict schema. Tools like Style Dictionary or simple 30-line Node scripts can regenerate CSS custom properties whenever a designer updates a single hex value.

Zero-dependency projects do not even need a build pipeline. Exporting design-tokens.json alongside ready-to-use tokens.css lets small teams paste CSS immediately while preserving a structured W3C archive for future redesigns.

Naming rules that prevent token sprawl

Stick to lowercase kebab-case or camelCase consistently across all keys and avoid naming colors after appearance like lightBlue2 or darkGrayAlt. Naming by function (surface, ink, primary, accent) keeps dark mode and rebrands painless.

Resist the temptation to export 400 unused spacing and shadow tokens. A compact 30-to-50 token file covers 95% of real marketing sites, SaaS interfaces, and documentation portals without overwhelming new developers.

Validating and versioning design-tokens.json in Git

Treat design-tokens.json like production source code rather than a static attachment buried in email threads. Whenever you update a primary color, base font size, or corner radius, commit the updated JSON alongside regenerated tokens.css and tailwind-brand.css files in one atomic pull request.

A lightweight Node script in CI can parse design-tokens.json, confirm every color token matches a valid 6-digit hex string, and verify that ink-on-surface and white-on-primary pairs still pass WCAG 2.2 AA (4.5:1) before merging.

Keep a top-level $description string noting the brand name and revision date. That single metadata field lets agencies and internal teams verify immediately whether a contractor's local repository is using the current brand release.

When sharing tokens across web, iOS, and Android apps, export neutral base dimensions in rem or px alongside documented conversion rules so mobile engineers map 16 px body text and 44 px minimum touch targets accurately to platform points and density-independent pixels without eyeballing screenshots.

  • Commit design-tokens.json in a predictable path such as /tokens/design-tokens.json or the repository root.
  • Never store raw pixel spacing values inside typography lineHeight tokens; use unitless ratios like 1.55.
  • Include 9-step primary and accent tonal ramps (100 through 900) so hover, border, and dark-mode shades stay mathematical.

Put these specifications to work immediately: Export W3C design-tokens.json for your brand.

Frequently asked questions

Why do W3C design token keys start with a dollar sign?

The $ prefix ($value, $type, $description) prevents collisions with real token names like value or type inside nested JSON objects.

Can Figma or Tokens Studio import W3C design-tokens.json?

Yes. Modern design token plugins and Style Dictionary v4 natively read the W3C $value and $type format without custom mapping scripts.

Should design-tokens.json store pixel or rem values for font sizes?

Store font sizes in rem (for example, 1rem and 1.25rem) so exported stylesheets respect user browser font-size settings under WCAG 1.4.4.