# 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 a file or stdin as a stream and writes to stdout or, with `-o`, atomically to a file, so multi-gigabyte input works and it fits in a shell pipeline. By default each run reads one JSON document; pass `-s`, `--stream`, or `--jsonl` on `flatten` or `search` to read JSON Lines / NDJSON (one value per line, numbered `json[0]`, `json[1]`, ... under `json = []`). Peak memory depends on document shape, nesting, token size, and flags; measured results are linked below. `--sort` spills buffered object lines above 64 MiB to a temp file, and out-of-order `unflatten` input is rebuilt in memory only when the problem shows up in the first 16 MiB (it fails past that). `unflatten` fills in missing parent containers automatically, so filtered gron such as `gronify search file.json term | gronify unflatten` or `gronify flatten file.json | grep term | gronify unflatten` rebuilds a valid JSON subset, just as `gron -u` and `fastgron -u` do. Numbers are printed exactly as written (`12345678901234567890`, `1.10`), as in gron and fastgron. Result caps (`search -m/--max-count`, `flatten --limit`) stop reading the input once reached, `--sort` gives a stable key order so two flattened files compare cleanly with system `diff`, and `search --exit-status` gives grep-style exit codes. These need 1.2.0 or newer. JSON Lines input (`-s`, `--stream`, `--jsonl`) and automatic missing-parent synthesis in `unflatten` need 1.4.0 or newer. Older versions fail with `error: unknown option '-m'` or `error: unknown option '-s'`; check with `gronify --version`. 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 and requires Node.js 20 or newer. ## Documentation - [Core workflow: flatten, search, unflatten](https://gronify.harlo.dev/#workflow): Print JSON as greppable `path = value` lines, filter them, and rebuild valid JSON. - [Comparison: jq, gron, fastgron, and grep](https://gronify.harlo.dev/#compare): When to use Gronify, `jq`, `gron`, `fastgron`, plain `grep`, or system `diff`, and where each of the others is the better tool. - [AI coding agents](https://gronify.harlo.dev/#agents): Count matches first (`--count`), stop reading early (`-m`, `--limit`), branch on `--exit-status`, and install the Gronify agent skills (`gronify-json-flatten-search`, `large-json-search`, `jsonl-ndjson-log-search`, `json-compare-sorted-diff`, `openapi-lockfile-json-search`, `json-path-to-jq-and-unflatten`). - [Command: flatten](https://gronify.harlo.dev/#commands): `gronify flatten [file]` prints JSON from a file or stdin as one line per value, in document order. Options: `--limit ` (stop after n lines and stop reading the input), `--sort` (sort object keys at every level by UTF-16 code unit; arrays keep their order; not the same order as gron), `-s, --stream, --jsonl` (read JSON Lines / NDJSON, one JSON value per line, flattened as `json[0]`, `json[1]`, ... under `json = []`). - [Command: search](https://gronify.harlo.dev/#commands): `gronify search [term]` flattens and filters in one pass. A term is a case-insensitive substring match on the whole line, path and value. Options: `-r, --regex` (JavaScript regular expression; `\d` works, POSIX classes such as `[[:digit:]]` do not), `-c, --case-sensitive`, `--count` (print the match count only), `-v, --invert-match`, `-m, --max-count ` (stop after n matches and stop reading the input), `--sort` (as for flatten; ignored with `--count`), `--exit-status` (exit 1 when nothing matches; errors then exit 2), `-s, --stream, --jsonl` (read JSON Lines / NDJSON, one JSON value per line). - [Command: unflatten](https://gronify.harlo.dev/#commands): `gronify unflatten [file]` turns gron lines from a file or stdin back into JSON. Lines in document order, which is what `flatten`, `flatten --sort`, and filtered `search` write, convert in one streaming pass; missing parent containers are filled in automatically. - [Global options](https://gronify.harlo.dev/#commands): `--color` (enable color), `--no-color` (plain output), `--pretty` (indented output), `-o, --output ` (write to a file, replaced only after the run succeeds), `-h, --help`, `-V, --version`. - [Benchmarks](https://gronify.harlo.dev/#benchmarks): Elapsed time, peak RSS, correctness, deep nesting, and result caps for Gronify, gron, fastgron, jq, and jaq. Check the source commit, run date, raw trials, and limits before quoting a result. [Methodology and every result](https://github.com/1solomonwakhungu/gronify/blob/main/src/packages/cli/BENCHMARKS.md). - [Install via npm](https://www.npmjs.com/package/gronify): `npm install -g gronify` on macOS, Linux, or Windows, or run once with `npx gronify --help`. CI tests Linux, macOS, and Windows. - [Install via Homebrew](https://gronify.harlo.dev/#install): `brew install 1solomonwakhungu/tap/gronify` - [Install from release archive](https://github.com/1solomonwakhungu/gronify/releases): Download the archive for the latest version. Requires Node.js 20 or newer. - [Build from source](https://gronify.harlo.dev/#install): Clone the repository, run `npm ci && npm run build && npm link` in `src/packages/cli`. - [Frequently asked questions](https://gronify.harlo.dev/#faq): What Gronify is, how to grep a JSON file, gron and jq compatibility, platforms, file size, number rounding, comparing two files, AI agents, privacy, invalid JSON, and speed. ## Playground - [JSON playground: flatten, grep, and unflatten JSON online](https://gronify.harlo.dev/playground): Paste JSON or JSON Lines and run `flatten`, `search` (with `--stream`, `--regex`, `-c`, `-v`, `--count`, `-m`, `--sort`), or `unflatten` in the browser, with the same output as the CLI and the equivalent `gronify` command to copy. Input stays in the browser and is limited to 2 MB; use the CLI for bigger files. ## Guides - [All guides](https://gronify.harlo.dev/guides): Index of the task guides below. Each guide answers one question with commands and real output. - [How to grep nested JSON from the command line](https://gronify.harlo.dev/guides/grep-json): Why plain `grep` prints a whole minified line or a key with no parent, and how `gronify search` locates each match by its full path. - [Search nested JSON in PowerShell and cmd without grep](https://gronify.harlo.dev/guides/grep-json-windows-powershell): `Select-String` and `ConvertFrom-Json` compared with `gronify search` on Windows, with the quoting rules that break searches in PowerShell (`"$ref"`) and cmd (`^`, single quotes). - [Flatten nested JSON to one line per value](https://gronify.harlo.dev/guides/flatten-json): How `gronify flatten` prints arrays, empty objects, and odd keys, and how to reverse it. - [Find the path to any key or value in a JSON file](https://gronify.harlo.dev/guides/find-json-path): Print the full path of a key or value with `gronify search`, turn it into a jq filter, or list paths with jq alone using `paths(scalars)`. - [Unflatten gron lines back into JSON (ungron)](https://gronify.harlo.dev/guides/unflatten-json): The round trip, rebuilding JSON subsets from filtered search or grep lines, which gron and fastgron output `gronify unflatten` reads, and editing values with `sed`. - [Compare two JSON files with `diff`, ignoring key order](https://gronify.harlo.dev/guides/compare-json-files): Flatten both files with `gronify flatten --sort` so the keys line up, then run the system `diff`. Every changed line shows the full path to its value. - [Search a multi-gigabyte JSON file from the command line](https://gronify.harlo.dev/guides/large-json-files): Why Node stops at `ERR_STRING_TOO_LONG` near 512 MB and jq parses the whole file first, and how to search the file as a stream with `gronify search` or `jq --stream`. - [Fix RangeError: Invalid string length when reading large JSON in Node.js](https://gronify.harlo.dev/guides/fix-err-string-too-long-json): Which calls throw `ERR_STRING_TOO_LONG` or `RangeError: Invalid string length` on JSON over about 512 MB, a streaming reader and writer that avoid it, and how to inspect the file with Gronify. - [Search OpenAPI specs, package-lock.json, and Kubernetes JSON from the command line](https://gronify.harlo.dev/guides/search-openapi-and-lockfiles): Path-anchored `gronify search` recipes for endpoints, auth schemes, deprecated operations, and `$ref` use in OpenAPI specs; versions, resolved URLs, and integrity hashes in `package-lock.json`; and fields in kubectl and AWS JSON. - [gron alternatives: gron, fastgron and Gronify compared](https://gronify.harlo.dev/guides/gron-alternative): Latest releases, install methods, output format, speed, memory on large files, and npm and Windows support, with dates. - [A jq alternative for exploring JSON you do not know yet](https://gronify.harlo.dev/guides/jq-alternative): jq transforms JSON whose structure you know. For a payload you have not seen, Gronify prints every path so you can find a value and write the jq filter. - [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 round integers above 2^53. jq 1.7 and newer keep a number as written until arithmetic touches it. - [Let a coding agent search large JSON without reading it all](https://gronify.harlo.dev/guides/json-for-ai-agents): Show the shape, count matches, and print a capped sample so a huge file never enters the context whole. Covers the agent skill install. ## Optional - [Full documentation](https://gronify.harlo.dev/llms-full.txt): Complete reference with all commands, options, exit codes, benchmarks, tool comparisons, AI agent workflows, guide summaries, pipeline recipes, and troubleshooting. - [Agent skills](https://skills.sh/1solomonwakhungu/gronify): Install all six Gronify skills with `npx skills add 1solomonwakhungu/gronify` (or `--skill gronify-json-flatten-search`). - [GitHub repository](https://github.com/1solomonwakhungu/gronify): Source code, CI, and contribution guidelines. - [Issues](https://github.com/1solomonwakhungu/gronify/issues): Bug reports and feature requests. - [License](https://github.com/1solomonwakhungu/gronify/blob/main/LICENSE): MIT License.