Recipe: Design token JSON writer

Generate a portable tokens.json from your Meridian config so every toolchain speaks the same visual language.

Why this matters

Meridian stores tokens in a typed, validated format. Exporting them as a flat JSON file lets you feed Figma plugins, Style Dictionary, Tailwind presets, and documentation sites from a single source of truth. No copy-paste drift.

Ingredients

  • Meridian CLI v2.1+
  • A meridian.config.ts with a complete tokens block
  • Node.js 20 LTS

Steps

  1. Audit your config.
    Open meridian.config.ts and confirm every token category — color, spacing, typography, shadow, radius — is populated. Missing entries become null in the output.
  2. Run the export.
    npx meridian export tokens --format json --out tokens.json
  3. Validate.
    npx meridian validate tokens.json
    Fix any warnings before sharing the file.
  4. Wire consumers.
    Point Style Dictionary, your Tailwind plugin, or Figma Tokens plugin at the generated file. Re-run the export whenever tokens change.

Output shape

{
  "color": {
    "brand": {
      "violet": { "value": "#8B5CF6" },
      "pink":   { "value": "#F472B6" }
    },
    "surface": {
      "dark": { "value": "#0A0612" }
    }
  },
  "spacing": { "md": { "value": "1rem" } },
  "fontSize": { "lg": { "value": "1.125rem" } }
}

CI integration

Add the export command to your build pipeline. On every push, Meridian regenerates tokens.json and fails the build if validation catches a drift. Keep design and code in lockstep without manual reviews.