A small JSON toolbox for Neovim: format, sort, extract JSON from logs, inspect JWTs, and copy JSONPaths.
- Handles log prefixes, quoted JSON strings, and apostrophes.
- Formatting failures leave your buffer untouched.
- JSONPath works with nested arrays and unusual keys, without Tree-sitter.
- Runs locally. No shell interpolation of document contents.
Decode synthetic JWT claims and expiration locally:
Requires Neovim 0.10+ and jq.
With lazy.nvim:
{
'hamidi-dev/json-kit.nvim',
opts = {
keys = {
pretty_split = '<leader>jp',
pretty_inplace = '<leader>jP',
sort = '<leader>js',
decode_jwt = '<leader>jw',
copy_path = '<leader>jy',
},
},
}Or call require('json-kit').setup(). No keys are mapped by default.
For a local checkout, replace the repository string with
dir = '~/SoftwareProjects/json-kit.nvim'.
| Command | Action |
|---|---|
JsonPrettySplit / JsonPrettyTab |
Format JSON from the current line; fall back to the buffer |
JsonExtractFromLine |
Extract JSON from a log line into a split |
JsonPrettyInPlace |
Format the buffer |
JsonSort [-v] |
Sort object keys recursively; -v opens a split |
JsonToggleMinify |
Toggle compact / pretty JSON |
JsonValidate |
Validate; show key count, array items, depth, and byte size |
JsonDecodeJWT |
Show decoded header, payload, and expiration |
JsonCopyPath |
Copy the cursor's JSONPath, e.g. $.users[1]["first.name"] |
JsonView |
Pass JSON at the cursor to your configured viewer callback |
All commands except JsonCopyPath accept line ranges, including visual
selections. In-place commands act on the whole buffer unless a range is given.
JWT decoding uses the current line or range; it does not verify signatures.
require('json-kit').setup({
jq = 'jq', -- executable or absolute path
timeout = 10000, -- milliseconds per subprocess
max_bytes = 2 * 1024 * 1024, -- input limit
keys = {}, -- only specified keys are mapped; false disables all
})Additional key names: extract, pretty_tab, sort_split, validate,
minify, view. Individual keys can be false.
Optional viewer = function(ctx) ... end connects your own tools: JsonView
passes { content = json_text, title = json_path } for the container at the
cursor, or validated JSON from a line range. See :help json-kit-viewer.
JSON input must be a single document (not JSONC or NDJSON). Statistics use root
depth zero and count members across all objects/arrays. Structural navigation
supports up to 128 nesting levels. Subprocesses are bounded by timeout and run
synchronously; increase input limits deliberately for large files.
:checkhealth json-kit checks dependencies. From the repository root:
nvim --headless -u NONE -i NONE -l tests/run.lua
stylua --check lua/ tests/MIT licensed.

