Chromaril CLI Reference
Chromaril CLI Reference
Installation
npm install -g @chromaril/cli
Or run via npx:
npx @chromaril/cli <command>
Global options
| Option | Description |
|---|---|
--help, -h | Display help for the CLI or a specific command |
Commands
validate
Validate one or more palette files against the Chromaril schema.
chromaril validate <file>
| Option | Description |
|---|---|
--format <format> | Output format: text (default) or json |
--glob | Treat <file> as a glob pattern |
Exit codes:
| Code | Meaning |
|---|---|
| 0 | All files valid |
| 1 | One or more files invalid |
| 2 | File 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>
| Option | Description |
|---|---|
--to <format> | Required. Target format. |
--output <path> | Required. Output file path. |
Supported formats:
| Format | Output |
|---|---|
json | Canonical, pretty-printed JSON |
css | CSS custom properties (variables) |
scss | SCSS variables |
tailwind | Tailwind CSS config excerpt |
json-flat | Flat 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>
| Option | Description |
|---|---|
--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) |
--glob | Treat <file> as a glob pattern |
Standard views:
| View | Description |
|---|---|
swatch-grid | Color swatches in a grid layout |
ui-mockup | UI component mockup with palette colors applied |
typography-sample | Text rendering sample with palette colors |
contrast-demo | Contrast pair demonstration |
image-overlay | Palette colors overlaid on an image |
gradient-strip | Gradient 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>
| Option | Description |
|---|---|
--output <path> | Required. Output package JSON file path. |
The source directory must contain:
- One or more
.palette.jsonfiles (palette documents) - An optional
assets/subdirectory (static assets bundled into the package) - An optional
chromaril.package.jsonmanifest with package metadata
Exit codes:
| Code | Meaning |
|---|---|
| 0 | Package created successfully |
| 1 | Invalid input or validation failure |
| 2 | Directory or file not found |
| 5 | Asset 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:
| Format | Extension | Role |
|---|---|---|
| JSON | .palette.json | Canonical interchange format |
| YAML | .palette.yaml, .palette.yml | Authoring 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
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Invalid input or validation failure |
| 2 | File not found |
| 3 | Unsupported format or view |
| 4 | Unknown or ambiguous variant selection |
| 5 | Asset read error |
| 6 | Unresolvable reference |
| 70 | Internal error |