Skip to main content
The HTVG CLI provides commands for compiling JSON element trees into SVG graphics.

compile

Compile an HTVG document to SVG format.
htvg compile <input> [OPTIONS]
input
string
required
Input JSON file path. Can be either:
  • A self-contained document with meta and content fields
  • A bare element tree (uses default metadata)

Options

--output
string
default:"stdout"
Output SVG file path. If not specified, outputs to stdout.Aliases: -o
--width
number
default:"800"
Override the output width in pixels. Takes precedence over width specified in document metadata.Aliases: -w
--pretty
boolean
default:"false"
Pretty-print the SVG output with indentation and line breaks.

Examples

Compile to stdout:
htvg compile input.json
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">...</svg>
Compile to file:
htvg compile input.json --output output.svg
Wrote output.svg (800x600)
Override width:
htvg compile input.json -w 1200 -o wide.svg
Wrote wide.svg (1200x900)
Pretty-print output:
htvg compile input.json --pretty
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
  <rect x="0" y="0" width="100" height="100" fill="#ff0000"/>
</svg>

Input Format

Self-contained document:
{
  "meta": {
    "width": 800
  },
  "content": {
    "type": "rect",
    "width": 100,
    "height": 100
  }
}
Bare element (fallback):
{
  "type": "rect",
  "width": 100,
  "height": 100
}

Error Handling

The command exits with status code 1 on errors:
htvg compile nonexistent.json
Error reading nonexistent.json: No such file or directory
htvg compile invalid.json
Compile error: unexpected token at line 1 column 5

version

Print version information.
htvg version
htvg 0.1.0

Examples

htvg version
htvg 0.1.0
Alternatively, use the standard --version flag:
htvg --version
htvg 0.1.0

Build docs developers (and LLMs) love