Skip to content
Latchkey

jc: Convert Command Output to JSON

jc parses the text output of dozens of CLI commands (df, ps, dig, ls, ifconfig, and many more) into structured JSON you can query with jq.

Many Unix commands print human-readable tables. jc knows their formats and converts them to JSON, so you can filter on fields instead of fragile awk column counting.

What it does

jc has a parser per supported command. Either pipe a command into jc --<parser> (for example jc --df), or use the magic syntax jc df -h where jc runs the command and picks the parser automatically. Output is JSON on stdout.

Common usage

Terminal
# pipe form: parse df output
df -h | jc --df
# magic syntax: jc runs the command and parses it
jc dig example.com
# combine with jq to extract a field
jc --ps | jq '.[] | select(.cpu_percent > 50) | .pid'

Options

Form / flagWhat it does
jc --<parser>Parse stdin with the named parser (e.g. --df, --ps)
jc <command> ...Magic syntax: run the command and auto-select a parser
-p, --prettyPretty-print the JSON output
-r, --rawLess processed output (no type conversions)
-a, --aboutList all available parsers
-m, --monochromeDisable colour

In CI

Drive a workflow from system state without parsing tables by hand: df -h | jc --df | jq -r ".[] | select(.use_percent > 90) | .filesystem" lists nearly full mounts to fail a job on. jc dig "$HOST" | jq .[].answer turns a DNS check into a clean assertion.

Common errors in CI

jc: command not found: pip install jc (or brew install jc). Using a parser whose output format differs on this OS yields wrong or empty fields, because jc parsers target a specific platform's output (GNU vs BSD ls/df differ); check jc -a for the parser notes. jc: Error - ... parser could not parse the input data means the input did not match the expected format, often because a flag changed the command's layout.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →