Skip to main content
This page documents all available options and flags for the HTVG CLI.

Global Options

These options are available for all commands.
--help
boolean
Display help information for the CLI or a specific command.Aliases: -h
--version
boolean
Display version information.Aliases: -V

Examples

Show general help:
htvg --help
HTVG - JSON element tree to SVG compiler

Usage: htvg <COMMAND>

Commands:
  compile  Compile an HTVG document to SVG
  version  Print version info
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version
Show command-specific help:
htvg compile --help
Compile an HTVG document to SVG

Usage: htvg compile [OPTIONS] <INPUT>

Arguments:
  <INPUT>  Input JSON file (self-contained document with meta + content)

Options:
  -o, --output <OUTPUT>  Output SVG file (defaults to stdout)
  -w, --width <WIDTH>    Override output width
      --pretty           Pretty-print the SVG output
  -h, --help             Print help
Check version:
htvg --version
htvg 0.1.0

compile Options

Options specific to the compile command.
--output
string
default:"stdout"
Specify the output file path for the generated SVG.Aliases: -oDefault behavior: When not specified, outputs to stdout, which allows piping to other commands.
--width
number
default:"800"
Override the output width in pixels.Aliases: -wDefault behavior:
  • For self-contained documents: Uses width from meta field if not overridden
  • For bare elements: Defaults to 800 pixels
  • CLI flag takes precedence over document metadata
--pretty
boolean
default:"false"
Format the SVG output with indentation and line breaks for human readability.Default behavior: Outputs minified SVG without extra whitespace.

Option Interactions

Width precedence: The --width flag overrides the width specified in document metadata:
# Document has meta.width = 800
htvg compile doc.json --width 1200
# Output will be 1200px wide, not 800px
Output redirection: When using --output, progress information is written to stderr:
htvg compile input.json -o output.svg
Wrote output.svg (800x600)
When outputting to stdout, only the SVG is written (to stdout):
htvg compile input.json > output.svg
# No progress message, just the SVG content

Examples

Combine multiple options:
htvg compile input.json --width 1920 --output poster.svg --pretty
Wrote poster.svg (1920x1080)
Pipe to other commands:
htvg compile input.json | xmllint --format -
Short flags:
htvg compile input.json -w 1200 -o output.svg
Wrote output.svg (1200x900)

Default Values Summary

OptionDefaultApplies ToNotes
--outputstdoutcompileWrites to stderr when file path is specified
--width800compileFor bare elements; self-contained docs use meta.width
--prettyfalsecompileMinified output by default

Exit Codes

The HTVG CLI uses standard exit codes:
CodeMeaningExample
0SuccessCompilation completed without errors
1ErrorFile not found, invalid JSON, compilation failure

Examples

Success:
htvg compile input.json -o output.svg
echo $?
Wrote output.svg (800x600)
0
Error:
htvg compile missing.json
echo $?
Error reading missing.json: No such file or directory
1

Build docs developers (and LLMs) love