style-dictionary is a free, open source build & deployment project written in JavaScript and released under Apache-2.0. It has 4,810 GitHub stars, 629 forks and 242 open issues, and was last pushed 8 days ago. On this registry it ranks #31 of 59 tracked projects in Build & Deployment, with 5 head-to-head comparisons available. It gained 3 stars over the last 3 tracked days.

What is style-dictionary?

Style Dictionary is a JavaScript build system that turns design tokens into cross-platform style definitions for iOS, Android, CSS, JavaScript, HTML, and Sketch, aimed at design-system teams and developers who need one source of truth for styles instead of hand-maintained files per platform.

What it is

Style Dictionary is an open-source build tool distributed through npm and written in JavaScript, licensed under Apache-2.0. It defines styles once as design tokens and then exports those tokens to every platform and language a project targets, including iOS, Android, CSS, JavaScript, HTML, Sketch files, and style documentation. The README summarises the idea as "Style once, use everywhere." The project is available as a command-line interface through npm, and it can also be used like a normal Node module when its functionality needs to be extended. Its topics describe it as a build system, a build tool, and a design-tools entry spanning design-systems, design-tokens, style-tokens, style, and styleguide.

The concrete problem it solves is style drift. When user experiences span multiple development platforms and devices, keeping styles consistent and synchronised is difficult, and designers, developers, and product managers all need style documentation that stays current. Mistakes happen anyway, and the design may not be implemented accurately. Style Dictionary replaces the manual practice of maintaining a separate, hand-edited set of colour, typography, and spacing definitions for each platform by automatically generating style definitions across all platforms from a single source, removing roadblocks, errors, and inefficiencies from that workflow.

Key capabilities

  • The style-dictionary build command generates styles, and only requires a config.json file in the project root.
  • Build flags include --config \[path\] / -c, --platform \[platform\] / -p, --help / -h, and --version / -v, so a single platform can be built in isolation.
  • A Node API exposes require('style-dictionary').extend('config.json') and StyleDictionary.buildAllPlatforms().
  • The .extend() method is overloaded and accepts a configuration object, for example { source: \['tokens/\*\*/\*.json'\], platforms: { scss: { transformGroup: ... } } }.
  • Platform-specific formats and transform groups are importable as named exports from style-dictionary/enums.
  • Outputs target several destinations from one token source, including iOS, Android, CSS, JS, HTML, Sketch files, and style documentation.
  • A browser-based playground at the Style Dictionary Play site allows experimenting without a local install.

Who uses it and how

  • Design-system teams maintaining a single token source that must reach native and web clients.
  • Product organisations shipping across multiple platforms where styles otherwise drift between iOS, Android, and CSS implementations.
  • Teams that already run a JavaScript build pipeline and want to extend Style Dictionary's functionality or invoke it from another build system such as Grunt or Gulp.
  • Designers, developers, and product managers who consume the generated style documentation for day-to-day communication.
  • Projects that install the CLI globally for local builds, or add it as a dev dependency when the configuration lives in the repository.

Getting started

Install globally with npm install -g style-dictionary and run style-dictionary build, or add it to a project with npm install -D style-dictionary / yarn add style-dictionary --dev; Node and npm are required. The only configuration needed is a config.json file.

How it compares

The provided facts do not name any paid products that Style Dictionary replaces, and they do not name any directly comparable open-source alternatives. On the evidence available, it stands alone in this registry.

When to use it — and when not to

A self-hoster must operate a Node and npm toolchain, and while the README does not mention a database, object storage, or SMTP dependency, it does require writing and maintaining a config.json and a token source such as tokens/**/*.json. Teams that ship on a single platform, or that cannot run Node and npm in their build environment, gain little from it. The repository carries 242 open issues and the README excerpt provided is truncated, so prospective adopters should read the full documentation and issue tracker before committing.

project readme (upstream, from github) — read inline
What's new in Style Dictionary 4.0!

npm version license PRs welcome GitHub Workflow Status downloads

Style Dictionary

See documentation

Style once, use everywhere.

A Style Dictionary uses design tokens to define styles once and use those styles on any platform or language. It provides a single place to create and edit your styles, and exports these tokens to all the places you need - iOS, Android, CSS, JS, HTML, sketch files, style documentation, etc. It is available as a CLI through npm, but can also be used like any normal node module if you want to extend its functionality.

When you are managing user experiences, it can be quite challenging to keep styles consistent and synchronized across multiple development platforms and devices. At the same time, designers, developers, PMs and others must be able to have consistent and up-to-date style documentation to enable effective work and communication. Even then, mistakes inevitably happen and the design may not be implemented accurately. Style Dictionary solves this by automatically generating style definitions across all platforms from a single source - removing roadblocks, errors, and inefficiencies across your workflow.

Watch the Demo on YouTube

Watch the video

Experiment in the playground

Try the browser-based Style Dictionary playground: https://www.style-dictionary-play.dev/, built by the folks at \RIOTS.

Contents

Installation

Note that you must have node (and npm) installed.

If you want to use the CLI, you can install it globally via npm:

$ npm install -g style-dictionary

Or you can install it like a normal npm dependency. This is a build tool and you are most likely going to want to save it as a dev dependency:

$ npm install -D style-dictionary

If you want to install it with yarn:

$ yarn add style-dictionary --dev

Usage

CLI

$ style-dictionary build

Call this in the root directory of your project. The only thing needed is a config.json file. There are also arguments:

Flag Short Flag Description
--config [path] -c Set the config file to use. Must be a .json file
--platform [platform] -p Only build a specific platform defined in the config file.
--help -h Display help content
--version -v Display the version

Node

You can also use the style dictionary build system in node if you want to extend the functionality or use it in another build system like Grunt or Gulp.

const StyleDictionary = require('style-dictionary').extend('config.json');

StyleDictionary.buildAllPlatforms();

The .extend() method is an overloaded method that can also take an object with the configuration in the same format as a config.json file.

import { formats, transformGroups } from 'style-dictionary/enums';

const StyleDictionary = require('style-dictionary').extend({
  source: ['tokens/**/*.json'],
  platforms: {
    scss: {
      transformGroup: transformGroups.scss,
      buildPath: 'build/',
      files: [
        {
          destination: 'variables.scss',
          format: formats.scssVariables,
        },
      ],
    },
    // ...
  },
});

StyleDictionary.buildAllPlatforms();

Example

Take a look at some of our examples

A style dictionary is a collection of design tokens, key/value pairs that describe stylistic attributes like colors, sizes, icons, motion, etc. A style dictionary defines these design tokens in JSON or Javascript files, and can also include static assets like images and fonts. Here is a basic example of what the package structure can look like:

├── config.json
├── tokens/
│   ├── size/
│       ├── font.json
│   ├── color/
│       ├── font.json
│   ...
├── assets/
│   ├── fonts/
│   ├── images/

config.json

This tells the style dictionary build system how and what to build. The default file path is config.json or config.js in the root of the project, but you can name it whatever you want by passing in the --config flag to the CLI.

{
  "source": ["tokens/**/*.json"],
  "platforms": {
    "scss": {
      "transformGroup": "scss",
      "buildPath": "build/",
      "files": [
        {
          "destination": "scss/_variables.scss",
          "format": "scss/variables"
        }
      ]
    },
    "android": {
      "transformGroup": "android",
      "buildPath": "build/android/",
      "files": [
        {
          "destination": "font_dimens.xml",
          "format": "android/fontDimens"
        }
      ]
    }
  }
}
Property Type Description
source Array An array of file path globs to design token files. Style Dictionary will do a deep merge of all of the token files, allowing you to organize your files files however you want.
include Array An array of file path globs to design token files that contain default styles. The Style Dictionary uses this as a base collection of tokens. The tokens found using the "source" attribute will overwrite tokens found using include.
platforms Object Sets of platform files to be built.
platform.transformGroup String (optional) Apply a group of transforms to the tokens, must either define this or transforms.
platform.transforms Array (optional) Transforms to apply sequentially to all tokens. Can be a built-in one or you can create your own.
platform.buildPath String (optional) Base path to build the files, must end with a trailing slash.
platform.files

readme truncated — read the full docs on github

Frequently asked questions

Is style-dictionary free to use?

style-dictionary is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does style-dictionary do?

A build system for creating cross-platform styles.

What is style-dictionary written in?

style-dictionary is primarily written in JavaScript. Its source is publicly available at https://github.com/style-dictionary/style-dictionary, and it has 4,810 GitHub stars.