Palette Format Reference

Palette Format Reference

Authoring

Palettes are authored as JSON or YAML files. JSON is the canonical interchange format and what the schema, app, and site consume at runtime. YAML is an authoring convenience — it is parsed, validated, and normalized through the exact same core path as JSON, and the CLI can convert YAML to canonical JSON for commit or pipeline use.

  1. Author in YAML (less syntax, no commas).

  2. Convert to JSON before committing:

    chromaril convert my-palette.palette.yaml --to json --output my-palette.palette.json
    

    Or let the pipeline handle conversion automatically.

JSON example (canonical)

{
  "chromaril": "1.0",
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "Ocean Breeze",
  "slug": "ocean-breeze",
  "colors": [
    { "name": "Deep Sea", "hex": "#1A3A5C" },
    { "name": "Seafoam", "hex": "#5DAFEC" },
    { "name": "Sandy Shore", "hex": "#F5E6CC" }
  ]
}

YAML example (equivalent)

chromaril: "1.0"
id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
name: "Ocean Breeze"
slug: "ocean-breeze"
colors:
  - name: "Deep Sea"
    hex: "#1A3A5C"
  - name: "Seafoam"
    hex: "#5DAFEC"
  - name: "Sandy Shore"
    hex: "#F5E6CC"

Both produce identical output when validated and normalized.

Embedded views

Palettes may declare embedded views (type: "embedded") with either format: "html" or format: "svg". The content field carries raw HTML or SVG markup authored by the palette creator.

Security contract for consumers

Embedded view content is untrusted input. Palette documents arrive via user import (editor-persistence), shared files, and third-party sources. A palette author may include arbitrary markup — including <script> tags, event handlers, or other executable surfaces — inside an embedded view’s content field.

Consumers of palette documents MUST sanitize embedded view content before injecting it into the DOM. The Chromaril web app implements this contract in two layers:

View formatRendering strategyRationale
svg<img> tag with a data:image/svg+xml,… data URIBrowsers do not execute script inside <img>-loaded SVGs — no sanitizer needed.
htmlSanitize with DOMPurify (allowlist: structural/text elements + inline styles; strip event handlers, <script>, <iframe>, javascript: URLs), then bind via v-html.DOMPurify is the industry-standard HTML sanitizer; the allowlist is documented in sanitize.ts.

Implementation reference

Standard views

Standard views (type: "standard") are rendered server-side by the @chromaril/renderer package. All palette-derived text fields (color names, hex values, palette name) are escaped with escapeXml before interpolation into SVG templates. The renderer produces well-formed XML even for hostile inputs containing <, >, &, ", and '.