A small, fast JSON CLI for the things you actually do every day: pretty-print, fold deeply nested trees, pluck out a single value, or build a JSON array from a list of lines. Reads from stdin or the system clipboard — copy a JSON blob, run jkit f, done.
| Command | Alias | What it does |
|---|---|---|
jkit format |
f |
Pretty-print JSON (4-space indent, keeps numeric precision) |
jkit cut <depth> |
c |
Collapse nodes deeper than <depth> into compact summaries |
jkit get <path> |
g |
Extract a sub-value by dotted path, e.g. data.items.0.id |
jkit maker |
m |
Turn line-separated text into a JSON string array |
go install github.com/wuhan005/jkit/cmd/jkit@latestFrom source:
git clone https://github.com/wuhan005/jkit.git
cd jkit
go install ./cmd/jkitRequires Go 1.21+. The binary is a single static file with no runtime dependencies.
jkit figures out where to read JSON from automatically:
- Pipe / redirect —
echo '{"a":1}' | jkit forjkit f < data.json - Clipboard — when stdin is a terminal, falls back to the system clipboard. Copy a JSON blob anywhere, then just run
jkit f.
If stdin has no data and the clipboard is empty,
jkitexits withno input from stdin or clipboard.
Pretty-print with 4-space indent. Numbers are decoded with json.Number, so big integers like 9223372036854775807 survive round-trip without becoming 9.2233720368e+18.
> echo '{"data":{"area":"东京Amazon数据中心","country":"日本","ip":"52.68.96.58"},"error":0,"msg":"success"}' | jkit f
{
"data": {
"area": "东京Amazon数据中心",
"country": "日本",
"ip": "52.68.96.58"
},
"error": 0,
"msg": "success"
}Collapse anything deeper than <depth> levels into { N items dict } / [ N items array ] summaries. Object keys are emitted in lexicographic order, so the same input always produces the same output (handy for diffs).
Omit <depth> to keep the full tree.
> jkit c 2
{
"code": 0,
"message": "success",
"result": {
"main_section": { 4 items dict },
"section": [ 1 items array ]
}
}Walk a .-separated path. Use integer indices for array elements. String leaves print without quotes (so you can pipe them straight into other tools); other leaves print as JSON literals.
> jkit g result.main_section.episodes.0
{
"badge": "会员",
"id": 341208,
"title": "1"
}
> jkit g result.main_section.episodes.0.title
1
> curl -s https://api.example.com/user | jkit g name | xargs -I{} echo "Hello {}"Errors include the path where things broke:
> echo '{"a":1}' | jkit g a.b
jkit: cannot descend into json.Number at a.bRead line-separated text, emit a JSON array. Empty lines are dropped, each line is trimmed, and \r\n is handled. Pass -u (or --unique) to drop duplicates.
> cat | jkit m
Hi, I'm E99p1ant. 🍆
🐭 Focus on Golang.
🏠 Blog at github.red.
[
"Hi, I'm E99p1ant. 🍆",
"🐭 Focus on Golang.",
"🏠 Blog at github.red."
]> printf 'apple\nbanana\napple\n' | jkit m -u
[
"apple",
"banana"
]MIT © wuhan005