Skip to content

Recipes

Real-world combinations of jkit with the rest of your terminal.

Inspect a giant API response

You hit an API and got back a wall of JSON. Use cut to see the shape first, then get to drill in.

bash
> curl -s https://api.example.com/data | jkit c 2

{
    "code": 0,
    "data": {
        "items": [ 50 items array ],
        "total": 50
    },
    "message": "ok"
}

> curl -s https://api.example.com/data | jkit g data.items.0

{
    "id": 1,
    "name": "first"
}

Use a JSON value as a shell variable

jkit g prints string leaves without quotes, so capture works naturally:

bash
> NAME=$(curl -s https://api.example.com/user | jkit g name)
> echo "Hello, $NAME"
Hello, alice

Diff two JSON payloads sanely

cut sorts keys, so the same logical content always renders identically — no more diff noise from random key order.

bash
diff <(jkit c < before.json) <(jkit c < after.json)

Format whatever's on your clipboard

The classic flow. Copy from a browser dev-tools network tab, then:

bash
jkit f

Build a JSON array from a markdown bullet list

Copy the bullets, then:

bash
> jkit m -u

[
    "Refactor the auth flow",
    "Migrate the cache layer",
    "Write the post-mortem"
]

Pipe through to jq if you need queries

jkit f and jq . are siblings, not rivals. Use them together:

bash
> echo '{"users":[{"id":1},{"id":2}]}' | jkit f | jq '.users[].id'
1
2

jkit shines for the 80% of "I just need to look at this JSON" cases. jq shines for actual querying.

Fold a config file before committing

Large generated config? Get a one-page overview with sorted keys before reading:

bash
jkit c 3 < config.json | less

Validate JSON in a script

Because jkit exits 1 on parse errors, you can use it as a cheap validator:

bash
if ! jkit f < payload.json > /dev/null 2>&1; then
    echo "Invalid JSON in payload.json" >&2
    exit 1
fi

Last updated: