# Gronify > Gronify is an open source CLI for grepping, searching, and flattening JSON from the command line. It prints every value on its own line with its full path, filters those lines by plain text or regex, and turns them back into JSON. Gronify is a gron-style CLI written in TypeScript and installed with `npm install -g gronify`. `flatten` prints one `json.path = value` line per value, `search` flattens and filters in one pass with plain text or a JavaScript regular expression, and `unflatten` (`ungron`) rebuilds JSON from gron lines. Search is built in, so no `grep` is needed. The CLI reads from files or stdin and writes to stdout or atomically to `-o `, so it fits in pipes, redirection, and other shell tools. By default each run reads one JSON document; pass `-s`, `--stream`, or `--jsonl` on `flatten` or `search` to read JSON Lines (NDJSON). Optional flags control colored output, pretty indentation, output files, case-sensitive and inverted matching, match counts, result caps, key sorting, JSON Lines streaming, and exit codes. Use Gronify when a large or unfamiliar JSON payload turns up in a CI log, an API response, a support bundle, or generated config, and you need to find a key or value before you know the schema. Use `jq` once you know the path and want to transform data. The project is open source under the MIT license. The current release is 1.4.0 (2026-11-22). Official website: . ## Features - Flatten JSON files or stdin into gron-style `json.path = value` lines, one per value, streaming large inputs with memory depending on document shape, nesting, token size, and options (`--sort` spills buffered object lines above 64 MiB to a temp file, and out-of-order `unflatten` input rebuilds in memory only when the problem shows up within the first 16 MiB). - Read JSON Lines / NDJSON (logs, API exports, agent transcripts) with `-s`, `--stream`, or `--jsonl` on `flatten` and `search`: each non-blank line becomes `json[0]`, `json[1]`, ..., under `json = []`, as with `gron -s` and `fastgron -s`. (1.4.0) - Unflatten (`ungron`) gron files or stdin back into JSON, streaming document-order input in one pass. Missing parent containers are filled in automatically, so filtered gron such as `gronify search file.json term | gronify unflatten` or `gronify flatten file.json | grep term | gronify unflatten` rebuilds valid JSON. (1.4.0) - Search the flattened lines, path and value, with plain text or a JavaScript regular expression. Matching can be case-sensitive or inverted, and `--count` prints only the number of matches. - Cap the output with `search -m/--max-count` and `flatten --limit`. Gronify stops reading the input at the cap, so early matches avoid scanning the rest of a large file. (1.2.0) - Sort object keys at every level with `--sort` for stable output that you can pass to system `diff`. The default is document order. (1.2.0) - Opt in to grep-style exit codes with `search --exit-status`. (1.2.0) - Keep numbers exactly as written: `12345678901234567890` and `1.10` come out unchanged. gron and fastgron do the same, and jq 1.7 and later does until a filter does arithmetic on the number. - Write output files atomically with `-o`: the target is replaced only after the run succeeds. - Use stdin/stdout workflows so Gronify can sit inside shell pipelines. - Format terminal output with optional colors and pretty indentation. ## Requirements - Node.js 20 or newer. - npm 10 or newer (only when building from source). - No external binaries are required at runtime. - Gronify 1.2.0 or newer for `-m/--max-count`, `--limit`, `--sort`, and `--exit-status`. Version 1.1.0 stops with `error: unknown option '-m'`. Check with `gronify --version` or `gronify search --help | grep -e --max-count`. - Gronify 1.4.0 or newer for JSON Lines input (`-s`, `--stream`, `--jsonl`) and automatic missing-parent synthesis in `unflatten`. Version 1.3.2 and older stop with `error: unknown option '-s'`. Check with `gronify flatten --help | grep -e --jsonl`. ## Installation ### npm ```bash npm install -g gronify # or run it once without installing npx gronify --help ``` Update an existing install with `npm install -g gronify@latest`. Published on [npm as `gronify`](https://www.npmjs.com/package/gronify). ### Homebrew Homebrew installs Gronify together with its Node.js dependency: ```bash brew install 1solomonwakhungu/tap/gronify ``` The formula is maintained in the [Homebrew tap](https://github.com/1solomonwakhungu/homebrew-tap). ### Release Archive Download the archive for the latest version from [GitHub Releases](https://github.com/1solomonwakhungu/gronify/releases). The executable requires Node.js 20 or newer. ### Build from Source 1. Clone and build Gronify. ```bash git clone https://github.com/1solomonwakhungu/gronify.git cd gronify/src/packages/cli npm ci npm run build ``` 2. Link the local CLI. ```bash npm link gronify --help ``` ## Command Reference ### Global Options | Option | Description | | --------------------- | ----------------------------------------------------------------------------- | | `--color` | Enable colored output when the terminal supports it. | | `--no-color` | Disable colored output. | | `--pretty` | Add indentation/grouping to formatted output. | | `-o, --output ` | Write output to a file instead of stdout. The file is replaced atomically. | | `-h, --help` | Show help. | | `-V, --version` | Show the CLI version. | ### `flatten [file]` Converts JSON to gron format. If `file` is omitted, Gronify reads from stdin. Keys come out in document order unless `--sort` is given. **Signature:** `gronify flatten [file]` #### Flatten Options | Option | Description | | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | `--limit ` | Stop after `n` lines of output and stop reading the input. `n` must be a positive integer. | | `--sort` | Sort object keys at every level by UTF-16 code unit. Array order is unchanged. | | `-s, --stream`, `--jsonl` | Read JSON Lines / NDJSON: one JSON value per line, flattened as `json[0]`, `json[1]`, ... under `json = []` (like `gron -s`). | **Examples:** ```bash gronify flatten data.json cat data.json | gronify flatten gronify flatten --sort --limit 100 data.json gronify flatten --stream events.jsonl ``` ### `unflatten [file]` Converts gron format back to JSON. If `file` is omitted, Gronify reads from stdin. **Signature:** `gronify unflatten [file]` **Examples:** ```bash gronify unflatten data.gron cat data.gron | gronify unflatten gronify search data.json region | gronify unflatten gronify --output data.json unflatten data.gron ``` `unflatten` streams. Gron in document order (each container before its children, siblings together, array indexes ascending), which is what `flatten`, `flatten --sort`, and filtered `search` write, converts in one streaming pass. Lines that end in `;`, as `gron` writes them, are accepted. - **Missing parents are filled in.** Filtered gron, such as `gronify flatten data.json | grep region | gronify unflatten` or `gronify search data.json region | gronify unflatten`, usually lacks the root and container lines. Gronify creates each missing container from the path segment that follows it, as `gron -u` and `fastgron -u` do: `.name` or `["name"]` means an object, `[3]` an array, and skipped array indexes become `null`. Filtered gron in document order streams in a single pass like full gron. Conflicting lines are still errors: a child under a scalar (`json.a = 1` then `json.a.b = 2`) or a property and an index on one container (`json.a = 1` then `json[0] = 2`). - **Out-of-order input.** Input that breaks document order is rebuilt in memory, whole, when the problem shows up within the first 16 MiB of input. Once 16 MiB of input has been read or 16 MiB of output produced, an out-of-order line fails with `line N: ...`. Plain `sort` on gron lines puts `[10]` before `[2]`, which forces that rebuild; `gronify flatten --sort` writes sorted lines in document order. - **Skipped array indexes become `null`.** `json[3] = 1` after `json = []` gives `[null,null,null,1]`. ### `search [term]` Searches the flattened lines. A term is matched against the whole line, path and value, so it can find a key, a value, or both at once (`"debug = true"`). Pass both a file and term, or pipe JSON to stdin and pass only the search term. **Signature:** `gronify search [term]` #### Search Options | Option | Description | | ------------------------- | ----------------------------------------------------------------------------------------------------------- | | `-r, --regex` | Treat the term as a JavaScript regular expression (`\d` works; POSIX classes such as `[[:digit:]]` do not). | | `-c, --case-sensitive` | Match case sensitively. | | `--count` | Print only the match count. | | `-v, --invert-match` | Show lines that do not match. | | `-m, --max-count ` | Stop after `n` matching lines (`n` non-matching lines with `-v`) and stop reading the input. | | `--sort` | Sort object keys at every level, as for `flatten`. Ignored with `--count`. | | `--exit-status` | Exit 1 when nothing matches, like `grep`. Errors then exit 2 instead of 1. | | `-s, --stream`, `--jsonl` | Read JSON Lines / NDJSON: one JSON value per line, flattened as `json[0]`, `json[1]`, ... under `json = []`. | Plain search terms are case-insensitive substring matches. `-c` means case-sensitive here, not count as in `grep`; counting is `--count`. **Examples:** ```bash gronify search data.json "user" gronify search data.json --regex "user\.[a-z]+" cat data.json | gronify search "name" gronify search data.json --count "field" gronify search data.json --case-sensitive "Service" gronify search data.json -m 20 "error" gronify search --exit-status config.json -m 1 "debug = true" gronify search --stream events.jsonl "timeout" ``` ### Result Caps `search -m/--max-count ` and `flatten --limit ` stop after `n` lines, following `grep -m`. Gronify stops reading the input at the cap, so the rest of the file is never read or validated; early matches avoid reading the rest of a large file, and `cat huge.json | gronify search -m 5 term` ends instead of waiting. The exit status is 0. When a cap ended the run, one line goes to stderr and stdout holds only gron lines: ```text Stopped after 20 matches (--max-count); there may be more ``` With `--count`, `-m` counts up to `n`. With `-o`, the capped output is committed atomically. With `--sort`, the cap applies to the sorted order, so a document whose root is an object is read to the end first. ### JSON Lines (NDJSON) `flatten` and `search` read JSON Lines (also called NDJSON or JSONL) when you pass `-s`, `--stream`, or `--jsonl`. Each non-blank line is one JSON value, and the output treats the file as one array of records (`json = []`, then `json[0]`, `json[1]`, ...), the same structure `gron -s` and `fastgron -s` print: ```bash printf '{"id":1,"level":"info"}\n\n{"id":12345678901234567890,"tags":["a"]}\n' | gronify flatten -s ``` ```text json = [] json[0] = {} json[0].id = 1 json[0].level = "info" json[1] = {} json[1].id = 12345678901234567890 json[1].tags = [] json[1].tags[0] = "a" ``` - Records are numbered from 0; blank and whitespace-only lines are skipped and `\r\n` endings are accepted. - One JSON value per line: a record may not span lines and a line may not hold two values. Errors report the line and byte offset. - Empty or whitespace-only input prints `json = []` and exits 0. - Records stream one at a time, including with `--sort`, and `--limit` / `-m` stop reading at the cap. - `gronify flatten -s logs.jsonl | gronify unflatten` rebuilds one JSON array of the records. Without `--stream`, JSON Lines fails at the second line and Gronify prints a tip to pass `--stream` (or `--jsonl`). ### Sorting Keys The default is document order. `--sort` on `flatten` or `search` sorts the keys of every object at every level: ```bash echo '{"b":1,"a":{"d":4,"c":3},"10":0,"2":0}' | gronify flatten --sort ``` ```text json = {} json["10"] = 0 json["2"] = 0 json.a = {} json.a.c = 3 json.a.d = 4 json.b = 1 ``` - Keys are compared by UTF-16 code unit, like JavaScript's default `sort()`, so `"10"` comes before `"2"`. - Each key's subtree stays together, and array elements keep their index order (`[2]` before `[10]`). - The output is stable: two documents that differ only in key order give identical lines, so `diff <(gronify flatten --sort a.json) <(gronify flatten --sort b.json)` shows real changes. - The output is in document order, so `gronify flatten --sort data.json | gronify unflatten` streams in one pass. - This is not gron's order. gron puts bare keys (`json.b`) before bracketed keys (`json["10"]`) at each level and compares UTF-8 bytes, so the two outputs can differ. It is also not what plain `sort` on the lines gives. - A top-level array is sorted record by record as it streams. An object is held until it closes: up to 64 MiB of line data stays in memory before spilling to a temp file in `$TMPDIR`, plus about 100–150 bytes per object member (a 1.5M-key object peaked at about 500 MB RSS). Set `GRONIFY_SORT_MEMORY` (bytes, or a size such as `256MiB`) to change the 64 MiB. ### Exit Codes | Code | Meaning | | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | `0` | Success, including a `search` with no matches (the default), a run stopped by `-m`/`--limit`, and a closed output pipe such as `\| head`. | | `1` | Failure: invalid JSON or gron, an unreadable or missing file, no input, an invalid option value, or an unknown option. With `search --exit-status`: no match. | | `2` | Only with `search --exit-status`: any failure from the list above. | ### Streaming and Large Inputs `flatten`, `search`, and document-order `unflatten` stream files or stdin and write output as they go. Peak memory depends on document shape, nesting, token size, flags, and output handling. `--sort` spills buffered object lines above 64 MiB to a temp file; out-of-order `unflatten` rebuilds in memory only when detected within the first 16 MiB and fails past that boundary. Use `--no-color` or `-o` for large unflatten output: colored output needs the whole document in memory. The benchmark section links measured time and peak RSS with the exact source revision, machine, commands, and raw trials. These measurements do not establish a fixed memory ceiling for arbitrary JSON. - **One document per run, unless you pass `--stream`.** By default the input is a single JSON value, and JSON Lines (one document per line) stops at the second line with `Unexpected '{' after the top-level value` and a tip to pass `--stream` (or `--jsonl`). Pass `-s`, `--stream`, or `--jsonl` to read JSON Lines; records stream one at a time. - **Strict JSON.** Trailing commas, comments, single quotes, invalid UTF-8, and data after the top-level value are rejected. Errors report the byte offset, line, and column, for example `Unexpected '}' after ',' (trailing commas are not allowed) at byte offset 7 (line 1, column 8)`. - **Invalid input on stdout.** Output is written while the input is still being read, so lines produced before an error may already be printed. Check the exit status in scripts. - A single string or number token must fit in memory. ## When to Use Gronify vs. jq, gron, fastgron, and grep - **vs. `jq` & `JSON.parse()`:** Use `jq` when you already know the path and need to reshape, filter, or compute; Gronify has no query language and does not transform data. Use Gronify to find the path when all you have is a key name or a value: a text or regex search prints each match with its full path, and the jq filter is written from that path. Gronify streams large files without extra flags, while Node cannot hand `JSON.parse()` a string over about 512 MB (`ERR_STRING_TOO_LONG`). On numbers: `JSON.parse()` rounds integers above `2^53`; jq 1.6 and older do too; jq 1.7 and later keeps a number as written when it passes through untouched and rounds it once a filter does arithmetic on it (`jq '.id + 0'`). jq 1.8.2 also respells exponents (`1E2` prints as `1E+2`). Gronify prints every number as written. - **vs. `gron` & `fastgron`:** All three print the same `json.path = value` lines, print numbers as written, read JSON Lines with `-s` (Gronify also accepts `--stream` and `--jsonl`), and rebuild JSON from grep-filtered lines with `unflatten` / `-u`. Gronify installs with `npm` on macOS, Linux, and Windows, searches by plain text or regex with counts and result caps in one command, keeps document order unless you pass `--sort`, and streams, so memory stays low on large files in both directions. `gron` is a single Go binary that needs no Node.js, sorts by default, leaves filtering to `grep`, and parses the whole document before it prints. `fastgron` is a C++ binary with a built-in fixed-string filter (`-F`) and path queries; it flattens and filters fixed strings faster than Gronify in this repository's benchmarks. The other two fetch URLs directly (with Gronify, pipe `curl -s` into it), and `fastgron` has path queries. Gronify is not a drop-in replacement for `gron`: its lines have no trailing `;`, so `gron -u` rejects them, while `gronify unflatten` and `fastgron -u` accept lines with or without it. - **vs. raw `grep` on JSON:** Running `grep` on minified JSON prints the whole file, because it is one line; on pretty-printed JSON it prints the matching key or value with no parent keys or array indexes. Gronify prints the full path on every line and has no nesting depth limit. - **With system `diff`:** Gronify has no `diff` subcommand. `flatten --sort` orders object keys by UTF-16 code unit at every nesting level, keeps each object's lines together, and leaves array indexes in numeric order (`[2]` before `[10]`), so `diff <(gronify --no-color flatten --sort old.json) <(gronify --no-color flatten --sort new.json)` ignores reordered keys and shows each real change with its full path. Arrays compare by position, so an element inserted at the front changes every later line; a structural tool such as `jd` handles that better. ## AI Coding Agents and Context-Safe Exploration Install the open Gronify skill suite for supported AI coding agents: ```bash npx skills add 1solomonwakhungu/gronify # or install one skill directly: npx skills add 1solomonwakhungu/gronify --skill gronify-json-flatten-search ``` Included skills on [skills.sh](https://skills.sh/1solomonwakhungu/gronify): - [`gronify-json-flatten-search`](https://skills.sh/1solomonwakhungu/gronify/gronify-json-flatten-search): Complete Gronify CLI workflow (flatten, search, JSONL, `--sort`, exit codes, `unflatten`). - [`large-json-search`](https://skills.sh/1solomonwakhungu/gronify/large-json-search): Context-safe exploration of over 50 KB, minified, compressed, or multi-GB JSON files. - [`jsonl-ndjson-log-search`](https://skills.sh/1solomonwakhungu/gronify/jsonl-ndjson-log-search): Streaming `.jsonl` / `.ndjson` log and transcript search with `--jsonl` / `-s` (Gronify 1.4.0+; falls back to `jq -c` on 1.3.2 and older). - [`json-compare-sorted-diff`](https://skills.sh/1solomonwakhungu/gronify/json-compare-sorted-diff): Key-order-independent JSON comparison using `flatten --sort` with system `diff` and `git diff`. - [`openapi-lockfile-json-search`](https://skills.sh/1solomonwakhungu/gronify/openapi-lockfile-json-search): Path-anchored regex recipes for OpenAPI/Swagger specs, `package-lock.json`, `kubectl -o json`, and cloud JSON. - [`json-path-to-jq-and-unflatten`](https://skills.sh/1solomonwakhungu/gronify/json-path-to-jq-and-unflatten): Find exact JSON paths for `jq` / JSONPath, keep 64-bit numbers exact, and unflatten subsets (automatic parent synthesis in 1.4.0+). When exploring unknown or multi-gigabyte JSON files inside an LLM session, always pass `--no-color` and narrow progressively from cheap to specific so the prompt context window is never flooded: ```bash gronify --no-color search payload.json error --count # 1. check match volume first gronify --no-color search payload.json error -m 20 # 2. inspect the first 20 matches gronify --no-color flatten --limit 50 payload.json # 3. inspect top-level schema shape gronify --no-color search payload.json --regex 'users\[[0-9]+\]\.email' -m 20 # 4. narrow with regex, still capped ``` Use `--exit-status` (`0` match, `1` no match, `2` error) for deterministic shell branching and `-o ` for atomic file output. ## Usage Examples ### Flatten a JSON File ```bash gronify flatten data.json ``` ### Flatten JSON from stdin ```bash echo '{"service":"api","retries":2}' | gronify flatten ``` ### Unflatten gron Output Back to JSON ```bash gronify flatten data.json | gronify unflatten ``` ### Search Flattened Paths ```bash gronify search data.json "service" gronify search data.json --regex "users\[[0-9]+\]\.name" gronify search data.json --case-sensitive "Service" gronify search data.json --count "error" ``` ### Use Gronify in a Pipeline ```bash curl -s https://example.com/payload.json | gronify search --regex "metadata|status" ``` ## Demo ### Sample Payload Create a sample payload: ```bash cat > demo.json <<'JSON' { "service": { "name": "checkout", "status": "degraded" }, "deployments": [ { "region": "us-central1", "version": "2026.05.22" }, { "region": "us-east1", "version": "2026.05.21" } ] } JSON ``` ### Flatten the Payload ```bash gronify flatten demo.json ``` Output: ```text json = {} json.service = {} json.service.name = "checkout" json.service.status = "degraded" json.deployments = [] json.deployments[0] = {} json.deployments[0].region = "us-central1" json.deployments[0].version = "2026.05.22" json.deployments[1] = {} json.deployments[1].region = "us-east1" json.deployments[1].version = "2026.05.21" ``` ### Search for Operationally Relevant Fields ```bash gronify search demo.json --regex "status|version" ``` Output: ```text json.service.status = "degraded" json.deployments[0].version = "2026.05.22" json.deployments[1].version = "2026.05.21" ``` ### Round-Trip Back to JSON ```bash gronify flatten demo.json | gronify unflatten ``` Output: ```json {"service":{"name":"checkout","status":"degraded"},"deployments":[{"region":"us-central1","version":"2026.05.22"},{"region":"us-east1","version":"2026.05.21"}]} ``` Add `--pretty` (`gronify flatten demo.json | gronify --pretty unflatten`) for indented output, which matches `JSON.stringify(value, null, 2)`. ### Stop After the First Match ```bash gronify search demo.json -m 1 "version" ``` Output (the second line is on stderr): ```text json.deployments[0].version = "2026.05.22" Stopped after 1 match (--max-count); there may be more ``` ## Pipeline Compositions ### Inspect a Remote API Response ```bash curl -s https://example.com/payload.json | gronify flatten ``` ### Search a Remote Payload ```bash curl -s https://example.com/payload.json | gronify search --regex "metadata|status" ``` ### Filter and Reconstruct Keep matching lines and turn them back into JSON. `unflatten` fills in missing parent containers automatically, including the root and intermediate objects or arrays: ```bash gronify search demo.json deployments | gronify unflatten gronify search demo.json version | gronify unflatten ``` Output: ```json {"deployments":[{"region":"us-central1","version":"2026.05.22"},{"region":"us-east1","version":"2026.05.21"}]} {"deployments":[{"version":"2026.05.22"},{"version":"2026.05.21"}]} ``` To remove a branch instead, use an inverted search: `gronify search demo.json -v deployments | gronify unflatten`. ### Count Matches ```bash gronify search data.json --count "error" ``` ### Case-Sensitive Search ```bash gronify search data.json --case-sensitive "Service" ``` ### Look at a Large File Without Printing All of It ```bash gronify search huge.json --count "error" # how many matches, before printing any gronify search huge.json -m 20 "error" # the first 20 matches, then stop reading gronify flatten --limit 50 huge.json # the first 50 lines ``` ### Use the Exit Status in a Script ```bash if gronify search --exit-status config.json -m 1 "debug = true" > /dev/null 2>&1; then echo "debug is on"; fi ``` ### Chain with Standard Shell Tools ```bash gronify flatten --sort data.json gronify flatten data.json | wc -l gronify search data.json "user" | head -20 ``` ## Benchmarks The benchmark page compares Gronify with gron, fastgron, jq (`jq --stream`), and jaq on generated records, deep nesting, exact-number fixtures, search, unflatten, and early-exit caps. - [Charts and interpretation](https://gronify.harlo.dev/#benchmarks) - [Methodology and all workload results](https://github.com/1solomonwakhungu/gronify/blob/main/src/packages/cli/BENCHMARKS.md) - [Raw trials and source provenance](https://github.com/1solomonwakhungu/gronify/blob/main/landing-page/src/app/benchmark-results.json) Use the recorded date, source SHA, versions, run count, commands, and limits when quoting results. The refreshed sweep reports median elapsed times with process startup included, retains raw attempts and failed/skipped outcomes, and uses a shared host. A 5% tie band is not a significance test. Output ordering and formatting differ across gron tools; jq emits parser events rather than gron assignments. Reproduce with `npm run bench:compare` from `src/packages/cli`. The raw results record the source commit and exact flags for the published sweep. ## Use Cases ### Incident Response Find status, version, region, and error fields in service payloads without opening an editor. ```bash gronify search payload.json --regex "status|version|error" ``` ### CI Investigation Inspect generated manifests and artifacts with grep-compatible output that fits existing scripts. ```bash gronify flatten build-output.json | grep "artifact" ``` ### Support Bundles Search deeply nested exports locally while keeping customer data inside your shell workflow. ```bash gronify search support-bundle.json "customer" ``` ### Configuration Review Compare meaningful paths instead of visually tracing braces through a large document. `--sort` gives both versions the same key order, so `diff` shows only real changes. ```bash diff <(gronify --no-color flatten --sort old.json) <(gronify --no-color flatten --sort new.json) ``` ## Playground runs `flatten`, `search`, and `unflatten` in the browser on pasted JSON, JSON Lines (NDJSON), or gron, with sample payloads (a service deployment, a minified event export, a JSON Lines request log, a big-integer ledger, and a config with keys out of order). It is a browser port of the CLI logic with the same output: numbers stay as written, `--sort` uses UTF-16 key order, `--stream` reads one JSON value per line, filtered `unflatten` synthesizes missing parents, and JSON errors give the byte offset, line, and column. Search supports `--stream`, `--regex`, `-c`, `-v`, `--count`, `-m`, and `--sort`; flatten supports `--stream`, `--sort`, and `--limit`; unflatten supports `--pretty`. The page shows the equivalent `gronify` or `npx gronify` command to copy. Input stays in the browser and is limited to 2 MB; the CLI streams files of any size. ## Guides Each guide answers one question with commands and output pasted from real runs. Index: . - [How to grep nested JSON from the command line](https://gronify.harlo.dev/guides/grep-json): Plain `grep` prints the whole document when JSON is minified and a bare key with no parents when it is pretty-printed. `gronify search` flattens and filters in one streaming pass and prints each match as `json.path = value`. The guide covers plain-text and JavaScript regex terms, case (search ignores it unless you pass `-c`), `--count`, `-m`, `-v`, `--exit-status`, `--stream` for JSON Lines, turning matches back into JSON with `unflatten`, and stdin from `curl` or `gzip`, and it names jq for selecting records by a condition and ripgrep for searching directories of many files. - [Search nested JSON in PowerShell and cmd without grep](https://gronify.harlo.dev/guides/grep-json-windows-powershell): `Select-String` matches lines with no JSON path, and `ConvertFrom-Json` answers questions only once you know the path; `ConvertTo-Json` truncates at depth 2 and `ConvertFrom-Json` rejects keys that differ only in case unless you pass `-AsHashtable` (PowerShell 6 and newer). `gronify search` runs the same in PowerShell, cmd, and Unix shells. The guide covers `--count`, `-m`, `--exit-status` with `$LASTEXITCODE`, pipelines, `-o`, and quoting: PowerShell expands `"$ref"` to an empty string, so use single quotes; cmd needs double quotes and reads `^` outside them. Gronify's CI runs the test suite on Windows, Linux, and macOS; the guide's transcripts are from PowerShell 7.4 on Linux. - [Flatten nested JSON to one line per value](https://gronify.harlo.dev/guides/flatten-json): `gronify flatten` prints one line per value, with a line for each object and array ahead of its contents. Array positions go in brackets, and a key that is not a plain ASCII identifier prints as a bracketed JSON string. The guide covers `--limit`, `--sort`, `-o`, `--pretty`, and `--stream` for JSON Lines, and says Gronify writes only this line form: for one flat object with dotted keys, jq or the npm package `flat` is the better tool. - [Find the path to any key or value in a JSON file](https://gronify.harlo.dev/guides/find-json-path): `gronify search` prints the full path next to each matching key or value. A pattern such as `\.email = ` pins the match to a key, and keeping ` = ` in the term pins it to the value side. Deleting the leading `json` turns the printed path into a jq filter, except that a key such as `$ref` must be written `.["$ref"]`. The guide also covers `--stream` for NDJSON and listing paths with jq alone (`paths(scalars)`, since `leaf_paths` was removed in jq 1.7). - [Unflatten gron lines back into JSON (ungron)](https://gronify.harlo.dev/guides/unflatten-json): `gronify unflatten` reads lines written by `gronify flatten`, gron, or fastgron and writes one JSON document with numbers and key order unchanged. Missing parent containers are filled in automatically, so filtered subsets from `gronify search` or `grep` rebuild valid JSON in one streaming pass when in document order. It also covers `-v` for dropping branches, editing a value with `sed`, conflicting paths, out-of-order input, and what is normalized (string escapes and whitespace). - [Compare two JSON files with `diff`, ignoring key order](https://gronify.harlo.dev/guides/compare-json-files): Gronify has no compare command. `gronify flatten --sort` writes both files with object keys in the same order and the system `diff` does the comparing, so reordered keys produce no output and each changed line carries its full path. Arrays compare by position: an element inserted at the front renumbers every later line, where `diff` on `jq -S` output reports one line, and the guide points to `jd` and `dyff` for arrays that shift or reorder. It also covers shells without process substitution and a git textconv driver. - [Search a multi-gigabyte JSON file from the command line](https://gronify.harlo.dev/guides/large-json-files): Node throws `Cannot create a string longer than 0x1fffffe8 characters` (`ERR_STRING_TOO_LONG`) when one string would pass about 512 MB, and jq without `--stream` parses the whole document before it prints. `gronify search` reads the file in chunks and tests each line as it is produced, so memory does not grow with the number of records. The guide covers `--count` and `-m`, gzip and zstd input through a pipe, the same search written with `jq --stream`, and Gronify's limits on large files. - [Fix RangeError: Invalid string length when reading large JSON in Node.js](https://gronify.harlo.dev/guides/fix-err-string-too-long-json): On a 582 MB file, `fs.readFileSync`, `JSON.parse` of a Buffer, and `require` threw `ERR_STRING_TOO_LONG`, while `fs.promises.readFile`, `data += chunk`, and `JSON.stringify` threw `RangeError: Invalid string length`. Both report V8's string limit (`buffer.constants.MAX_STRING_LENGTH`, 536,870,888), so `--max-old-space-size` does not help. The guide shows a stream-json reader, a writer that stringifies one record at a time, and inspecting the file with `gronify flatten --limit`, `search --count`, `-m`, and `unflatten` to pull out one record as JSON. - [Search OpenAPI specs, package-lock.json, and Kubernetes JSON from the command line](https://gronify.harlo.dev/guides/search-openapi-and-lockfiles): Regexes anchored on the printed path answer common questions about large everyday files: endpoint counts, the operations on a path, an `operationId`, deprecated operations versus deprecated schema properties, security schemes, and which endpoints use a `$ref` in the GitHub and Stripe OpenAPI descriptions; every installed copy of a package, its dependents, resolved URL, integrity hash, a non-registry URL check with `--exit-status`, and install scripts in `package-lock.json`; kinds, images, and Secret data in kubectl JSON; and records in the AWS `ip-ranges.json`. YAML specs go through `yq -o=json`. Conditions on two fields of one record need jq. - [gron alternatives: gron, fastgron and Gronify compared](https://gronify.harlo.dev/guides/gron-alternative): Checked against gron 0.7.1, fastgron 0.7.7, and Gronify 1.4.0 (with benchmark figures from the 2026-11-05 sweep on Gronify 1.3.1). In the project's benchmark fastgron flattened whole files fastest and Gronify used far less memory on large files because it streams; gron has the widest packaging, and its latest release is from April 2022. All three read JSON Lines with `-s` and rebuild grep-filtered subsets; the guide lists what gron and fastgron do that Gronify does not (URL input and fastgron's path queries), the output differences that break scripts (gron sorts keys and ends lines with `;`), and that the npm package named `gron` is a different project. - [A jq alternative for exploring JSON you do not know yet](https://gronify.harlo.dev/guides/jq-alternative): Gronify does not replace jq, which is the right tool for reshaping, filtering, and computing over JSON whose structure you know. For a payload you have not seen, `gronify flatten --limit` and `gronify search` print full paths with their values, where jq needs a new filter for each question. The guide turns a printed path into a jq filter in three edits and sorts other jq alternatives by kind: jq implementations (jaq, gojq), interactive viewers (fx, jless, jnv), and flatteners (gron, fastgron). - [Why big integers change in jq, and how to keep them exact](https://gronify.harlo.dev/guides/json-number-precision): jq 1.6 and older read every number into a 64-bit float, so an integer above 2^53 is rounded when it is parsed. jq 1.7 and newer print a number as written unless the filter does arithmetic on it: on jq 1.8.2, `.id + 0` rounds a 64-bit id, while comparison, `select`, `sort`, and `tostring` keep it. gron 0.7.1, fastgron 0.7.7, and Gronify 1.3.1 all print numbers unchanged, so exact numbers are not a reason to pick one of them over another. The guide also covers `JSON.parse` in Node and Python's `json` module. - [Let a coding agent search large JSON without reading it all](https://gronify.harlo.dev/guides/json-for-ai-agents): An agent that reads a large minified JSON file whole spends its context on records it does not need. The guide's loop is shape (`flatten --limit`), volume (`search --count`), a sample (`-m`), then exact paths and values with a narrower term or regex, with `--stream` for JSON Lines logs. Input after a cap is never parsed or validated, so a capped result is a sample. It also covers `--no-color`, `--exit-status`, `-o`, the six Gronify agent skills on skills.sh, and lines to paste into `CLAUDE.md` or `AGENTS.md`. ## Troubleshooting ### `npm test` Fails Before Running Assertions Build first so `dist/index.js` exists: ```bash npm run build npm test ``` ### JSON Does Not Flatten Gronify accepts strict JSON only, one document per run (or one JSON value per line with `-s`, `--stream`, or `--jsonl`). The error names the byte offset, line, and column of the first problem, for example `Unexpected '}' after ',' (trailing commas are not allowed) at byte offset 7 (line 1, column 8)`. Trailing commas, comments, and single quotes are rejected. JSON Lines input without `--stream` fails at line 2 with `Unexpected '{' after the top-level value` and a tip to pass `--stream` (or `--jsonl`). ### `unflatten` Says `property does not match its parent container` Two lines disagree about what a container is: for example, `json.a = 1` followed by `json.a.b = 2` puts a child under a scalar, and `json.a = 1` followed by `json[0] = 2` uses the root as both an object and an array. Missing parents are not the cause in 1.4.0 and newer, because `unflatten` fills them in automatically. Gronify 1.3.2 and earlier did not fill in missing parents and reported `root must be assigned before child paths` instead. ### No Output from Search Verify the search term matches the flattened path format. Use `gronify flatten --limit 50 ` first to see the paths, then refine the search term. ### `error: unknown option '-m'` or `error: unknown option '-s'` The installed Gronify is older than the version that added the flag (`-m`, `--limit`, `--sort`, and `--exit-status` need 1.2.0+; `-s`, `--stream`, and `--jsonl` need 1.4.0+). Update with `npm install -g gronify@latest` or `brew upgrade gronify`. ## Architecture Gronify is a standalone TypeScript CLI built with commander.js for the command interface and chalk for colored terminal output. The CLI processes JSON locally: it makes no network requests and has no telemetry. The source code is organized under `src/packages/cli` within the repository. Integration tests run the built CLI directly and require no external binaries. ## Repository Layout ```text . |-- branding/ # Logo and icon assets |-- docs/ # Benchmark receipts and review notes |-- landing-page/ # Next.js marketing/demo page |-- scripts/ # Repository validation and package discovery helpers |-- skills/ # Open agent skills suite (6 skills indexed by skills.sh) |-- skills.sh.json # Repository skill groupings for skills.sh |-- src/ | |-- README.md # Source tree orientation | `-- packages/cli/ # TypeScript CLI package `-- .github/ # CI, Dependabot, and contribution templates ``` ## Development The CLI package lives in `src/packages/cli`. ```bash cd src/packages/cli npm ci npm run build npm test ``` Useful package scripts: ```bash npm run lint npm run format:check npm run build npm test npm run audit ``` ## Contributing See [CONTRIBUTING.md](https://github.com/1solomonwakhungu/gronify/blob/main/CONTRIBUTING.md) for the development workflow and pull request expectations. ## Security See [SECURITY.md](https://github.com/1solomonwakhungu/gronify/blob/main/SECURITY.md) for vulnerability reporting guidance. ## License Gronify is licensed under the [MIT License](https://github.com/1solomonwakhungu/gronify/blob/main/LICENSE). ## Credits - [gron](https://github.com/tomnomnom/gron) established the greppable JSON workflow that inspired this project. - [commander.js](https://github.com/tj/commander.js) powers the command interface. - [chalk](https://github.com/chalk/chalk) powers colored terminal output. ## FAQ **What is Gronify?** Gronify is an open source command-line tool that flattens JSON into one line per value, each with its full path, so you can search nested data with plain text or a regex. It is modeled on gron, has search and unflatten built in, and streams its input, so multi-gigabyte files work. **How do I grep or search a JSON file from the command line?** Run `gronify search file.json term`. Gronify flattens the file and prints each matching line as `path = value`, so you see where the match sits. A plain term is a case-insensitive substring match on the whole line. Add `--regex` for a JavaScript regular expression, `-c` for exact case, or `--count` for a total. From a pipe, pass only the term: `curl -s URL | gronify search status`. **Is Gronify a drop-in replacement for gron?** No. Gronify uses the same `path = value` lines, but the commands and the output differ. The commands are `gronify flatten` and `gronify unflatten`, where gron uses `gron` and `gron --ungron`. Lines have no trailing semicolon. Keys stay in document order unless you pass `--sort`, while gron sorts by default. `--sort` compares keys by UTF-16 code unit; gron puts bare keys before bracketed ones and compares UTF-8 bytes. `gronify unflatten` reads gron's output and fills in parents missing from grep-filtered lines, just as `gron --ungron` does. `gron --ungron` does not read Gronify's output, which lacks the semicolons. **Is Gronify an alternative to jq?** For finding data, yes. For transforming it, no. jq can report paths too, but you have to write a filter for it. Gronify shows you the path when all you have is a key name or a value. It also prints numbers exactly as written and streams large files without extra flags. Gronify has no query language, so keep jq for reshaping, arithmetic, and building new JSON. **Does Gronify work on Windows, macOS, and Linux?** Yes. Gronify is a Node.js program, so `npm install -g gronify` works on all three with Node.js 20 or newer. Search is built in, so PowerShell and cmd users do not need `grep`. Homebrew, a GitHub release archive, and a source build are also available. CI runs the test suite on Linux, macOS, and Windows. **How large a JSON file can Gronify handle?** Gronify has no built-in size limit, because `flatten`, `search`, and `unflatten` read their input in chunks and write output as they go. Measured runs on multi-gigabyte input are in the [benchmarks](https://gronify.harlo.dev/#benchmarks). Memory depends on the document and the flags. One string or number must fit in memory. `--sort` holds each object's lines and spills to a temp file past 64 MiB. Unflatten input that is out of document order is rebuilt in memory only when the problem shows up in the first 16 MiB; after that it fails. Colored unflatten output builds the whole document, so pass `--no-color` for very large input. **Does Gronify round large numbers the way JSON.parse does?** No. Gronify checks that each number is valid JSON and prints it exactly as written, so `12345678901234567890`, `1.10`, `-0`, and `1e-7` come through `flatten`, `search`, and `unflatten` unchanged. `JSON.parse` rounds integers above 2^53 (9007199254740992) to the nearest double. jq 1.7 and later keeps a number as written when it passes through untouched, but rounds it once a filter does arithmetic on it. **How do I compare two JSON files from the command line?** Flatten both files with `--sort` and give the output to your system's `diff`. In bash or zsh: `diff <(gronify --no-color flatten --sort old.json) <(gronify --no-color flatten --sort new.json)`. `--sort` puts object keys in the same order on both sides and leaves arrays in index order, so reordered keys produce no output. Gronify has no `diff` command of its own. In PowerShell or cmd, write each side to a file with `-o` and compare the files. **How do AI coding agents use Gronify on large JSON files?** They count first, then read a capped sample. `gronify --no-color search file.json term --count` prints how many lines match. `search -m 20` prints the first 20 matches and stops reading the file, and `flatten --limit 50` shows the shape of the document. A large file never enters the model's context whole. The Gronify agent skills on skills.sh (`gronify-json-flatten-search`, `large-json-search`, and four task-focused skills) teach supported agents this routine. **Does Gronify send my JSON data anywhere?** No. Gronify reads files and stdin on your machine and writes to stdout or a local file. It makes no network requests and has no telemetry. **What does Gronify do with invalid JSON?** It stops with exit code 1 (2 with `search --exit-status`) and an error that names the byte offset, line, and column, such as: `Unexpected '}' after ',' (trailing commas are not allowed) at byte offset 7 (line 1, column 8)`. Gronify accepts strict JSON only, so trailing commas, comments, single quotes, and invalid UTF-8 are errors. By default each run expects one JSON document; pass `-s`, `--stream`, or `--jsonl` to read JSON Lines (NDJSON). Lines before the error may already be printed, so check the exit code in scripts. **How fast is Gronify compared with gron and fastgron?** It depends on the workload. In this repository's benchmarks, fastgron flattens and filters fixed strings faster than Gronify. Gronify uses less memory on large files because it streams, including when it turns gron back into JSON, while gron parses the whole document before it prints. A capped search (`-m`) stops reading once it has enough matches, so a late or absent match still means scanning more input. Process startup is included in every timing and can dominate small inputs. Dated figures, exact commands, and raw trials are in the [benchmarks](https://gronify.harlo.dev/#benchmarks) and [BENCHMARKS.md](https://github.com/1solomonwakhungu/gronify/blob/main/src/packages/cli/BENCHMARKS.md).