Chromaril CLI Reference

Chromaril CLI Reference

Installation

npm install -g @chromaril/cli

Or run via npx:

npx @chromaril/cli <command>

Global options

OptionDescription
--help, -hDisplay help for the CLI or a specific command

Commands

validate

Validate one or more palette files against the Chromaril schema.

chromaril validate <file>
OptionDescription
--format <format>Output format: text (default) or json
--globTreat <file> as a glob pattern

Exit codes:

CodeMeaning
0All files valid
1One or more files invalid
2File not found

Examples:

# Validate a single file
chromaril validate my-palette.palette.json

# Validate all palette files in a directory
chromaril validate "palettes/*.palette.json" --glob

# JSON output for CI pipelines
chromaril validate my-palette.palette.json --format json

Input files may be JSON (.palette.json) or YAML (.palette.yaml, .palette.yml).

convert

Convert a palette file to a design-token format or canonical JSON.

chromaril convert <file> --to <format> --output <path>
OptionDescription
--to <format>Required. Target format.
--output <path>Required. Output file path.

Supported formats:

FormatOutput
jsonCanonical, pretty-printed JSON
cssCSS custom properties (variables)
scssSCSS variables
tailwindTailwind CSS config excerpt
json-flatFlat JSON key/value map

Examples:

# Convert YAML to canonical JSON
chromaril convert my-palette.palette.yaml --to json --output my-palette.palette.json

# Generate CSS custom properties
chromaril convert my-palette.palette.json --to css --output theme.css

# Generate SCSS variables
chromaril convert my-palette.palette.json --to scss --output _theme.scss

# Generate Tailwind config
chromaril convert my-palette.palette.json --to tailwind --output tailwind.colors.js

render

Render a standard view of a palette to SVG or PNG.

chromaril render <file> --view <view> --output <path>
OptionDescription
--view <view>Required. Standard view type.
-o, --output <path>Required. Output file path (or directory with --glob).
--format <format>Output format: svg (default) or png
--scale <scale>Pixel scale factor for PNG output (default: 1)
--variant <selection...>Variant selection(s): dimension=name or exact variant name
--width <width>Output width in pixels (default: 1200)
--height <height>Output height in pixels (default: 720)
--globTreat <file> as a glob pattern

Standard views:

ViewDescription
swatch-gridColor swatches in a grid layout
ui-mockupUI component mockup with palette colors applied
typography-sampleText rendering sample with palette colors
contrast-demoContrast pair demonstration
image-overlayPalette colors overlaid on an image
gradient-stripGradient strip across all palette colors

Examples:

# Render a swatch grid as SVG
chromaril render my-palette.palette.json --view swatch-grid -o swatch.svg

# Render as PNG at 2x scale
chromaril render my-palette.palette.json --view ui-mockup -o mockup.png --format png --scale 2

# Render with a variant applied
chromaril render my-palette.palette.json --view swatch-grid -o swatch.svg --variant theme=dark

# Batch render all palettes in a directory
chromaril render "palettes/*.palette.json" --glob --view swatch-grid -o output/

pack

Bundle one or more palettes with optional assets into a package document.

chromaril pack <directory> --output <path>
OptionDescription
--output <path>Required. Output package JSON file path.

The source directory must contain:

  • One or more .palette.json files (palette documents)
  • An optional assets/ subdirectory (static assets bundled into the package)
  • An optional chromaril.package.json manifest with package metadata

Exit codes:

CodeMeaning
0Package created successfully
1Invalid input or validation failure
2Directory or file not found
5Asset read error

Example:

# Package a directory of palettes
chromaril pack ./my-package --output my-package.chromaril.json

Input formats

The CLI accepts palette documents in two authoring formats:

FormatExtensionRole
JSON.palette.jsonCanonical interchange format
YAML.palette.yaml, .palette.ymlAuthoring convenience

YAML input is parsed, validated, and normalized through the same core path as JSON. The convert command can produce canonical JSON from either format.

All commands that accept a file path also accept YAML files. The CLI detects the format from the file extension automatically.

Exit codes

CodeMeaning
0Success
1Invalid input or validation failure
2File not found
3Unsupported format or view
4Unknown or ambiguous variant selection
5Asset read error
6Unresolvable reference
70Internal error

See also