Tokens

Token JSON format

How to write valid token JSON in SXL Studio: DTCG structure, core fields, the full type set, aliases, math, color modifiers, and validation — every section opens with a table.

Overview

This page describes the JSON format for token files in the Tokens tab. It follows the DTCG shape ($value, $type, $extensions, …). For component files ($type: "composition"), see Composition.

Every node is either a token or a group:

Node typeRuleCan hold
Token nodeHas $value$value, $type, $description, $extensions, $id
Group nodeNo $value (a container)Child nodes + inherited $type / $extensions

Key idea Any key starting with $ is a DTCG metadata field. Any other key is a group or token name. Groups pass $type and $extensions down to their children.


File root

The root must be a JSON object (arrays, strings, and numbers are rejected by validation).

JSON
{
  "colors": {
    "brand": {
      "primary": {
        "$value": "#635BFF",
        "$type": "color"
      }
    }
  }
}

Core fields

FieldRequiredDescription
$valueYes (for token node)The token's value (see forms below)
$typeNoToken type — explicit or inherited from a parent group
$descriptionNoHuman-readable description
$extensionsNoFigma metadata (figma.scopes, codeSyntax, hide, modify)
$idNoStable ID for external tooling

$value forms

FormExample
String"#635BFF", "16px", "Inter"
Number / Boolean8, true
Pure alias"{colors.brand.primary}"
Math expression"{spacing.base} * 2"
Object (composite)typography, border, grid, …
Array (composite)effects, shadow layers, fill layers, …

String:

JSON
{ "$value": "#635BFF", "$type": "color" }
{ "$value": "16px", "$type": "spacing" }
{ "$value": "Inter", "$type": "fontFamily" }

Number / Boolean:

JSON
{ "$value": 8, "$type": "number" }
{ "$value": true, "$type": "boolean" }

Pure alias — one dot-notation path inside {...}:

JSON
{ "$value": "{colors.brand.primary}", "$type": "color" }

Math expression (alias embedded in a string):

JSON
{ "$value": "{spacing.base} * 2", "$type": "spacing" }
{ "$value": "clamp(16px, {spacing.base} * 4, 64px)", "$type": "sizing" }

Object / Array (composite values):

JSON
{
  "$value": { "fontFamily": "Inter", "fontSize": "16px", "fontWeight": 500, "lineHeight": "24px" },
  "$type": "typography"
}
JSON
{
  "$value": [{ "type": "DROP_SHADOW", "x": 0, "y": 2, "blur": 8, "spread": 0, "color": "#00000033" }],
  "$type": "shadow"
}

Token types ($type)

SXL Studio supports 38 canonical token types. What each type does on Export Variables & Styles is the clearest way to group them.

Exported as Figma variables (17) — scalar tokens that become variables in a collection.

Figma variable kindTypes
COLORcolor
FLOAT (number)opacity, dimension, number, spacing, sizing, borderWidth, borderRadius, fontSize, lineHeight, letterSpacing, paragraphIndent, paragraphSpacing
STRINGfontFamily, fontWeight, text
BOOLEANboolean

Exported as Figma styles (10) — composite tokens that become local styles.

Style kindTypes
Paintgradient, img, fill
Effectshadow, backdrop-blur, blur, glass, effects
Texttypography
Gridgrid

Internal / editable only (11) — fully editable in SXL Studio and used by plugin logic or rendering, but not exported directly as a variable or style: border, strokeStyle, fontStyle, textCase, textDecoration, transition, duration, cubicBezier, template, composition, custom.

Full per-type behavior: Token types.

Note custom (or a clean project-specific $type such as "baseUnit") stays editable in SXL Studio. On export, SXL infers a safe target from the $value shape (#112233 → color, numbers → number, booleans → boolean, CSS gradients → paint). Values it cannot infer safely stay opaque/internal.


$type normalization

Legacy and plural $type values are normalized automatically to the canonical key.

InputCanonical
stringtext
sizesizing
spacespacing
fontFamiliesfontFamily
fontWeightsfontWeight
fontStylesfontStyle
fontSizesfontSize
lineHeightslineHeight
letterSpacingsletterSpacing
paragraphSpacingsparagraphSpacing
paragraphIndentsparagraphIndent
borderRadiiborderRadius
textCasestextCase
textDecorationstextDecoration
backdropBlur / backgroundBlur / background-blurbackdrop-blur
layerBlurblur
boxShadowshadow

Tokens Studio exports (legacy value / type / extensions) can be converted through Migrate from Tokens Studio.


Type resolution and inference

$type is resolved in this order:

PrioritySource
1Token-level $type
2Nearest parent group $type
3Root-level $type
4Auto-inference from $value (fallback)

If nothing resolves, validation reports an error. When no $type is present or inherited, the parser infers from the $value shape:

$value shapeInferred type
true / false or "on", "off", "yes", "no", "1", "0"boolean
Number literal (12, 0.5)number
Numeric string with unit (16px, 1.5rem, 50%, 200ms)number
Color string (#…, rgb(…), hsl(…), color(…))color
CSS gradient (linear-gradient(…), radial-…, conic-…)gradient
Stringified 4-number array ("[0.4, 0, 0.2, 1]")cubicBezier
Object with r / g / bcolor
Object with typography fields (fontFamily, fontSize, …)typography
Object/array with shadow fields (offsetX/Y, blur+color)shadow
Object/array with grid fields (pattern, sectionSize, …)grid
Object/array with fill/paint fieldsfill
Object with blur onlyblur
Pure alias ("{a.b}")resolved from the alias target

Tip Inference is a fallback for convenience. For reliable exports, set $type explicitly (at token, group, or root level).


$extensions

KeyWhat it does
figma.scopesVariable scope hints for Figma variable export
figma.codeSyntaxDev Mode code snippets (Web, Android, iOS)
figma.hideHide the variable from publishing
figma.modifyColor modifiers (lighten, darken, alpha, mix)

figma.scopes — variable scope hints for export:

JSON
{ "$extensions": { "figma.scopes": ["ALL_FILLS", "STROKE_COLOR"] } }

The full scope list and per-type defaults live on Scopes & Code Syntax.

figma.codeSyntax — Dev Mode snippets. Use the keys exactly as shown: Web, Android, iOS.

JSON
{
  "$extensions": {
    "figma.codeSyntax": {
      "Web": "var(--color-brand-primary)",
      "Android": "@color/brand_primary",
      "iOS": "Color.brandPrimary"
    }
  }
}

figma.hide — hide the variable from publishing:

JSON
{ "$extensions": { "figma.hide": true } }

figma.modify — color modifiers:

FieldValues
typelighten, darken, alpha, mix
valueAmount (01)
spacesrgb, hsl, lch, oklch, p3 (default oklch)
colorTarget color — required for mix
JSON
{ "$extensions": { "figma.modify": { "type": "lighten", "value": 0.2, "space": "oklch" } } }

figma.modify can be a single object or an array chain applied in order:

JSON
{
  "$extensions": {
    "figma.modify": [
      { "type": "lighten", "value": 0.12, "space": "oklch" },
      { "type": "alpha", "value": 0.6 }
    ]
  }
}

If space is omitted, SXL Studio defaults to oklch. space also accepts the alias $space.

Inheritance. Group $extensions are inherited by children and merged shallowly — a child key overrides the same parent key, and non-overlapping keys combine.

JSON
{
  "brand": {
    "$type": "color",
    "$extensions": { "figma.scopes": ["ALL_FILLS"] },
    "primary": { "$value": "#635BFF" },
    "primary-soft": {
      "$value": "{brand.primary}",
      "$extensions": { "figma.modify": { "type": "alpha", "value": 0.7 } }
    }
  }
}

Aliases

FormSyntaxUse
Pure"{colors.brand.primary}"The whole value is one referenced token
Embedded"{spacing.base} * 3"Reference inside a math / composite string

Rules: one path inside braces, dot notation for segments, no circular references. A pure alias ("{a.b}") is treated as an alias — not as math — and its type resolves from the target token.


Math expressions

A $value string containing an operator or function is evaluated after aliases resolve.

Math applies to numeric token types only: dimension, number, spacing, sizing, borderWidth, borderRadius, opacity, fontSize, lineHeight, letterSpacing, paragraphSpacing, paragraphIndent, duration, blur, backdrop-blur — and to numeric fields inside composites (shadow offsets/blur/spread, typography sizes, transition timings). String-kind values are never evaluated: a text token "37-37" stays the literal "37-37", not 0.

CategorySupported
Operators+, -, *, /, %, parentheses
Constantspi, e
Roundinground, floor, ceil, trunc
Clampingmin, max, clamp
Arithmeticabs, sign, mod, pow, sqrt, hypot
Exp / logexp, log, log2, log10
Trigonometrysin, cos, tan, asin, acos, atan, atan2
JSON
{ "$value": "{spacing.base} * 4", "$type": "spacing" }
{ "$value": "round({spacing.base} * 1.5, 2)", "$type": "spacing" }

Notes: round(x, n) rounds to n decimals; rem / em and seconds are normalized during evaluation; an unresolved alias or unknown function invalidates the expression.


Validation

The JSON editor validates:

  • JSON syntax;
  • DTCG parse errors (a missing resolvable $type; unknown $type values are kept as editable opaque custom tokens);
  • malformed alias braces;
  • unknown token references.

For composition / template files, string references are also checked against workspace token paths, including local embedded composition token namespaces.


Full example

JSON
{
  "color": {
    "$type": "color",
    "brand": {
      "primary": {
        "$value": "#635BFF",
        "$description": "Primary brand color",
        "$extensions": {
          "figma.codeSyntax": {
            "Web": "var(--color-brand-primary)",
            "Android": "@color/brand_primary",
            "iOS": "Color.brandPrimary"
          }
        }
      },
      "primary-soft": {
        "$value": "{color.brand.primary}",
        "$extensions": {
          "figma.modify": [
            { "type": "lighten", "value": 0.1, "space": "oklch" },
            { "type": "alpha", "value": 0.65 }
          ]
        }
      }
    }
  },
  "spacing": {
    "$type": "spacing",
    "base": { "$value": "4px" },
    "md": { "$value": "{spacing.base} * 4" }
  }
}