Gron – Make JSON Greppable

Last modified on November 08, 2020

Build Status

Maintain JSON greppable!

gron transforms JSON into discrete assignments to hold out it easier to grep for what you scheme terminate to admire and glimpse absolutely the 'course' to it.
It eases the exploration of APIs that return immense blobs of JSON however admire gradual documentation.

gron "" | fgrep "commit.creator"
json[0]"2016-07-02T10: 51: 21Z";
json[0].commit.creator.identify="Tom Hudson";

gron can work backwards too, enabling you to reveal your filtered information once more into JSON:

▶ gron "" | fgrep "commit.creator" | gron --ungron
    "commit": {
      "author": {
        "date": "2016-07-02T10:51:21Z",
        "email": "",
        "name": "Tom Hudson"

Disclaimer: the GitHub API has inconceivable documentation, nevertheless it makes for a factual instance.


gron has no runtime dependencies. That you merely might maybe additionally precise obtain a binary for Linux, Mac, Home home windows or FreeBSD and escape it.
Put the binary in your $PATH (e.g. in /usr/native/bin) to hold out it simple to make use of:

▶ tar xzf gron-linux-amd64-0.1.5.tgz
▶ sudo mv gron /usr/native/bin/

Must you're a Mac specific particular person you can also furthermore arrange gron by strategy of brew:

▶ brew arrange gron

Or for these that're a Ride specific particular person you can also use hasten rep (for these that're the utilization of Ride 1.7 or newer):

▶ hasten rep -u

It's actually useful that you just simply alias ungron or norg (or each!) to gron --ungron. Put one thing esteem this in your shell profile (e.g. in ~/.bashrc):

alias norg="gron --ungron"
alias ungron="gron --ungron"

Or you'll be able to obtain a shell script in your $PATH named ungron or norg to admire an ticket on all customers:

gron --ungron "$@"


Obtain JSON from a file:

▶ gron testdata/two.json 

From a URL:

▶ gron

Or from stdin:

▶ curl -s | gron

Grep for one thing and effortlessly glimpse the hasten to it:

▶ gron testdata/two.json | grep twitter"@TomNomNom";

gron makes diffing JSON simple too:

▶ diff mail="";

The output of gron is legitimate JavaScript:

▶ gron testdata/two.json> tmp.js
▶ echo "console.log(json);">> tmp.js
▶ nodejs tmp.js
{ contact: { e-mail: '', twitter: '@TomNomNom' },
  github: '',
  likes: [ 'code', 'cheese', 'meat' ],
  identify: 'Tom' }

It's furthermore possibly to assemble the gron output as JSON flow into by strategy of
the --json swap:

▶ curl -s | gron --json


gron can furthermore flip its output once more into JSON:

▶ gron testdata/two.json | gron -u
  "contact": {
    "e-mail": "",
    "twitter": "@TomNomNom"
  "github": "",
  "likes": [
  "identify": "Tom"

This suggests you exhaust can use gron with grep and numerous devices to change JSON:

▶ gron testdata/two.json | grep likes | gron --ungron
  "likes": [


▶ gron --json testdata/two.json | grep likes | gron  --json --ungron
  "likes": [

To retain array keys, arrays are padded with null when values are lacking:

▶ gron testdata/two.json | grep likes | grep -v cheese
▶ gron testdata/two.json | grep likes | grep -v cheese | gron --ungron
  "likes": [

Must you rep inventive you can also invent some quite neat strategies with gron, and
then ungron the output once more into JSON.

Obtain Wait on

▶ gron --aid
Remodel JSON (from a file, URL, or stdin) into discrete assignments to hold out it greppable

  gron [OPTIONS] [FILE|URL|-]

  -u, --ungron     Reverse the operation (flip assignments once more into JSON)
  -c, --colorize   Colorize output (default on tty)
  -m, --monochrome Monochrome (invent no longer colorize output)
  -s, --circulate     Treat every line of enter as a separate JSON object
  -k, --afraid   Disable certificates validation
  -j, --json       Disclose gron information as JSON flow into
      --no-kind    Don't type output (sooner)
      --version    Print model information

Exit Codes:
  0	OK
  1	Failed to originate file
  2	Failed to be taught enter
  3	Failed to type statements
  4	Failed to catch URL
  5	Failed to parse statements
  6	Failed to encode JSON

  gron /tmp/apiresponse.json
  curl -s | gron
  gron | grep firm | gron --ungron


Wasn't this written in PHP earlier than?

Yes it turned as soon as! The typical model is preserved right here for posterity.

Why the artificial to Ride?

Largely to bewitch away PHP as a dependency. There is a substantial amount of of us who work with JSON who invent no longer admire PHP put in.

Why mustn't I precise use jq?

jq is superior, and so much more principal than gron, however with that vitality comes
complexity. gron aims to hold out it easier to make use of the devices you understand, esteem grep and sed.

gron's foremost trustworthy is to hold out it simple to derive the hasten to a label in a deeply nested JSON blob
if you happen to invent no longer already know the construction; unparalleled of jq's vitality is unlocked supreme when that construction.

Read More

Similar Products:

    None Found

Recent Content