jshon
Parse and manipulate JSON from the command line
SYNOPSIS
jshon [-Cklpqrtun] [-d precision] [-e element] [-i element=data] [-s data] [-F from[,to]] [file...]
PARAMETERS
-C
Compact output (no whitespace)
-d precision
Set decimal places for numbers (default 15, 0-17)
-e element
Extract (step into) element(s) by key or index; repeatable
-F from[,to]
Delete slice from array (to defaults to end)
-i element=data
Insert or replace data at element key
-k
With -e, output keys instead of values
-l
Output length of array or string
-n
Output JSON null
-p
Pretty-print with indentation
-q
Quiet mode; skip bad JSON, continue
-r
Raw string output (no quotes/escapes)
-s data
Add literal string data
-t
Test JSON validity only (exit 0/1)
-u
Unstringify (output keys as raw strings)
DESCRIPTION
jshon is a small, fast C-based utility for parsing, querying, and editing JSON data from files or stdin. It supports extracting elements by key, inserting or deleting data, pretty-printing, compacting output, and testing JSON validity. Designed for efficiency with minimal footprint (<100KB binary), it uses the jsmn parser for quick single-pass processing. Ideal for shell scripts, embedded systems, or anywhere jq is too heavy. Multiple -e options drill down paths (e.g., -e foo -e bar). Supports numbers, strings, arrays, objects, and basic operations like slicing arrays or raw output. Output is valid JSON unless modified with flags like -r. Processes multiple files sequentially, writing to stdout.
CAVEATS
Limited to simple paths (repeat -e); no complex queries, regex, or functions like jq. Arrays indexed by number strings only. No streaming for huge files; loads entirely. UTF-8 support but may mishandle some escapes. Duplicate keys ignored unless -m (if available).
EXAMPLES
echo '{"foo": "bar"}' | jshon -e foo
bar
jshon -p file.json
Pretty-prints JSON.
echo '{}' | jshon -s hello -i msg
{"msg":"hello"}
jshon -e items -e 0 -e name file.json
Drills into nested object.
HISTORY
Developed 2009-2012 by Jan Klemkow using Serge Zaitsev's jsmn parser. Popular in minimal distros (Alpine, Slackware) pre-jq era for its tiny size and speed. Maintained sporadically; last major updates ~2013.


