Skip to content
Take valid JSON on stdin, then output it as discrete assignments to make it grep-able
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Gron's purpose is to turn JSON into grep-able, but still valid, JavaScript.

Gron is written in PHP. It requires PHP 5.2 or newer.


Pipe JSON into Gron's stdin:

~# cat test-input.json | ./gron
json = {};
json["one"] = 1;
json["two"] = 2;
json["three-b"] = "3";
json["four"] = [];
json["four"][0] = 1;
json["four"][1] = 2;
json["four"][2] = 3;
json["four"][3] = 4;
json["five"] = {};
json["five"]["alpha"] = [];
json["five"]["alpha"][0] = "fo";
json["five"]["alpha"][1] = "fum";
json["five"]["beta"] = {};
json["five"]["beta"]["hey"] = "How's tricks?";

The idea is that you can grep the result to find what you're looking for, and where it exists in the JSON structure:

~# cat test-input.json | ./gron | grep tricks
json["five"]["beta"]["hey"] = "How's tricks?";

This is useful when exploring unfamiliar APIs that have large responses but lacklustre documentation.

Gron can also fetch JSON straight from files:

~# ./gron test-input.json | grep tricks
json["five"]["alpha"][1] = "fum";

Or from URLs:

~# ./gron
json = {};
json["salt"] = "$2a$11$6rm6zQm3DaQQqZYjXerBjf";

Exit codes

Gron's exit code depends on what happened:

0 - Success
1 - Failed to decode JSON
2 - Argument is not valid file or URL
3 - Failed to fetch data from URL


Put Gron in your $PATH (e.g. /usr/bin/gron) so you don't have to use the "./":

~# sudo mv gron /usr/bin/gron
~# cat test-input.json | gron

Instead of:

~# cat test-input.json | ./gron
Something went wrong with that request. Please try again.