dtcg-tools
v1.2.1
Published
CLI for validating DTCG JSON tokens, converting JSON to CSS, and generating HTML showcase from JSON or CSS (files, URLs, or stdin).
Maintainers
Readme
dtcg-tools
CLI for DTCG 2025.10 design tokens.
It validates token JSON, converts JSON tokens to CSS variables, and generates a static HTML showcase from JSON or CSS.
Install
Run without installing:
npx dtcg-tools validate tokens.jsonOr install globally:
npm install -g dtcg-tools
dtcg-tools validate tokens.jsonRequires Node.js 18 or newer.
Commands
| Command | Accepts | Output |
| --- | --- | --- |
| validate | JSON file, JSON URL, stdin JSON | validation result |
| convert | JSON file, JSON URL, stdin JSON | CSS |
| showcase | JSON/CSS file, JSON/CSS URL, stdin JSON/CSS | HTML showcase |
Validate
dtcg-tools validate tokens.json
dtcg-tools validate https://example.com/tokens.json
cat tokens.json | dtcg-tools validateUse another validation engine:
dtcg-tools validate tokens.json --engine ajv
dtcg-tools validate tokens.json --engine allEngines: dispersa default, ajv, terrazzo, all.
Convert
Print CSS to stdout:
dtcg-tools convert tokens.json
dtcg-tools convert https://example.com/tokens.json
cat tokens.json | dtcg-tools convertWrite CSS to a file:
dtcg-tools convert tokens.json --output tokens.css
dtcg-tools convert https://example.com/tokens.json --output tokens.cssConvert multiple JSON inputs to multiple CSS files:
dtcg-tools convert light.json dark.json --output light.css --output dark.cssconvert accepts only JSON inputs, because it converts DTCG JSON to CSS.
Showcase
Generate HTML from JSON:
dtcg-tools showcase tokens.json
dtcg-tools showcase https://example.com/tokens.jsonGenerate HTML from CSS:
dtcg-tools showcase tokens.css
dtcg-tools showcase https://example.com/tokens.cssMix inputs. Each input becomes a tab:
dtcg-tools showcase light.css dark.json https://example.com/brand.jsonWrite HTML to a file and open it in the default browser:
dtcg-tools showcase tokens.json --output showcase.htmlRead from stdin:
cat tokens.json | dtcg-tools showcase
cat tokens.css | dtcg-tools showcaseNotes
--output name.htmlwrites to a temporary directory.--output path/name.htmlwrites to that path.- Repeating
--outputforconvertmust match the number of JSON inputs.
License
MIT
