npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@design-token-kit/core

v0.3.3

Published

Core library for Design Token Kit: validate, convert, showcase.

Readme

@design-token-kit/core

The core package of Design Token Kit provides the runtime foundation for working with DTCG 2025.10 design tokens. It defines the typed token model, performs schema and semantic validation, converts tokens into CSS custom properties, and renders static HTML showcases.

Features

  • DTCG 2025.10 validation - schema validation for DTCG JSON token documents
  • Semantic checks - unresolved references, circular references, group references, type mismatches, and deprecated token usage
  • HRDT YAML support - a compact, human-readable alternative to DTCG JSON
  • Token format conversion - read and write DTCG JSON and HRDT YAML
  • CSS generation - base and theme token sets rendered as CSS custom properties
  • Static showcase - HTML showcase generation from token sources or existing CSS
  • Source abstraction - local files, stdin, URLs, and raw token content strings

Node.js 18 or newer is required.

Install

npm install @design-token-kit/core

Quick Start

import {
  DtcgListLoader,
  DtcgTokenValidator,
  DtcgTokenCssConverter,
  createTokenHtmlShowcase,
} from "@design-token-kit/core";

const sources = ["./tokens.json", "./tokens.dark.yaml"];

const issues = await new DtcgTokenValidator().validate(sources);
if (issues.some((issue) => issue.severity === "error")) {
  console.error(issues);
  process.exit(1);
}

const list = await new DtcgListLoader().load(sources);
const css = new DtcgTokenCssConverter().convertList(list);
const html = await createTokenHtmlShowcase().showcase(sources);

console.log(css);
console.log(html.slice(0, 120));

Input Formats

DTCG JSON

Use DTCG JSON token documents as the canonical source format for validation, conversion, and showcase generation.

HRDT YAML

Use HRDT YAML for a more compact, human-readable authoring format. HRDT documents are parsed into the same internal Dtcg model as DTCG JSON.

Base and theme sources

When multiple token sources are provided, the first source is treated as the base token set and the remaining sources are treated as theme overrides.

CSS input for showcase

For showcase generation, a single CSS source can be rendered directly without going through token validation.

Output Formats

CSS custom properties

Generate token sets as CSS variables with a :root block for base tokens and :root[data-theme="<theme>"] blocks for theme overrides.

HTML showcase

Render a static HTML preview from DTCG JSON, HRDT YAML, or existing CSS custom properties.

Serialized token documents

Convert token documents between DTCG JSON and HRDT YAML, or write a parsed document back to either source format.

Main APIs

  • DtcgTokenValidator - validate DTCG JSON and HRDT YAML token sources
  • DtcgListLoader - load base and theme sources into a DtcgList
  • DtcgJsonReader / HrdtTokenReader - parse supported token formats
  • DtcgJsonWriter / HrdtTokenWriter - export token documents
  • DtcgTokenCssConverter - generate CSS custom properties from tokens
  • createTokenHtmlShowcase() - generate an HTML preview from token sources or CSS

Validation

Use DtcgTokenValidator when you want the full validation pass:

  • DTCG schema checks
  • HRDT schema checks
  • semantic checks on the resolved token graph
import { DtcgTokenValidator } from "@design-token-kit/core";

const issues = await new DtcgTokenValidator().validate([
  "./tokens.json",
  "./tokens.dark.json",
]);

for (const issue of issues) {
  console.log(
    issue.severity,
    issue.sourcePath,
    issue.tokenPath,
    issue.message,
  );
}

Use DtcgSchemaValidator when you only need DTCG schema validation without semantic checks.

Document Conversion

Use readers and writers to convert token documents between DTCG JSON and HRDT YAML.

import {
  DtcgJsonReader,
  HrdtTokenWriter,
} from "@design-token-kit/core";

const doc = new DtcgJsonReader().parse(jsonString);
const yaml = new HrdtTokenWriter().write(doc);

CSS Conversion

DtcgTokenCssConverter emits:

  • base tokens under :root
  • theme overrides under :root[data-theme="<theme>"]
  • aliases as var(--token-name)
import { DtcgTokenCssConverter } from "@design-token-kit/core";

const css = await new DtcgTokenCssConverter().convert([
  "./tokens.json",
  "./tokens.dark.json",
]);

When you already have a parsed document or a prepared DtcgList, use convertDocument() or convertList() instead of reloading sources.

HTML Showcase

Use createTokenHtmlShowcase() for the default pipeline or TokenHtmlShowcaseBuilder when you want to inject your own validator, converter, parser, or renderer.

import { createTokenHtmlShowcase } from "@design-token-kit/core";

const html = await createTokenHtmlShowcase().showcase([
  "./tokens.yaml",
]);