LinuxCommandLibrary

gron

Transform JSON into discrete assignments

TLDR

Process JSON file into individual assignments

$ gron [path/to/file|url]
copy

Don't sort output data
$ gron --no-sort [path/to/file|url]
copy

Disable certificate validation
$ gron [[-k|--insecure]] [url]
copy

Display values of gron assignments
$ gron [[-v|--values]] [path/to/file|url]
copy

Turn assignments converted with gron back into JSON
$ gron [[-u|--ungron]] [path/to/file|url]
copy

Process individual lines of input as separate JSON objects
$ gron [[-s|--stream]] [path/to/file|url]
copy

Represent processed data as a JSON stream
$ gron [[-j|--json]] [path/to/file|url]
copy

SYNOPSIS

gron [-c CLAMP] [-m MATCH] [-f FORMAT] [-r ROOT] [-u] [-k] [-v] [files...] | stdin

PARAMETERS

-h, --help
    Show context-sensitive help.

--version
    Show application version.

-c, --clamp=CLAMP
    Only show matching paths (like jq --stream).

-m, --match=MATCH
    Only include paths matching this regex.

-u, --unquoted
    Don't quote strings in output.

-k, --pure
    Output values only (no key names).

-f, --format=FORMAT
    Format output using this Go template.

-r, --root=ROOT
    Prepend ROOT to all paths.

-v
    Be verbose.

DESCRIPTION

Gron is a fast, lightweight command-line tool that converts JSON into discrete, grep-friendly lines. Each line represents a path to a JSON value in the format json.path.to.value = "actual value", preserving the original order and making it simple to search, filter, and edit JSON using standard Unix tools like grep, sed, and awk.

Unlike traditional JSON processors such as jq, which require learning a query language, gron eliminates nesting complexity. For example, input JSON becomes flat paths like users[0].name = "Alice". This approach excels for ad-hoc querying, log analysis, and scripting where performance matters.

Written in Go, gron is memory-efficient for moderately large files (up to gigabytes) and supports regex matching, clamping to specific paths, custom formatting via Go templates, and more. It's ideal for developers and sysadmins tired of jq's learning curve.

CAVEATS

Loads entire JSON into memory, so very large files (>10GB) may cause issues.
Deeply nested JSON can produce extremely long lines.
Does not validate JSON (use jsonlint first if needed).

BASIC USAGE

gron data.json | grep -i "error"
gron data.json | sed 's/false/true/g' | gron -u --pure

PIPING BACK

To convert back: gron input.json | ...edits... | gron -u --pure | undgron > output.json (requires companion undgron tool).

HISTORY

Developed by Tom Hudson (tomnomnom) starting in 2016. Written in Go for speed and simplicity. Gained popularity via GitHub (10k+ stars) for solving jq usability pain points. Latest releases add features like Go templates.

SEE ALSO

jq(1), jless(1), json_pp(1)

Copied to clipboard