Skip to content

Instantly share code, notes, and snippets.

@wolfgangmeyers
Last active August 29, 2015 14:15
Show Gist options
  • Save wolfgangmeyers/7a113d313371db6e07b9 to your computer and use it in GitHub Desktop.
Save wolfgangmeyers/7a113d313371db6e07b9 to your computer and use it in GitHub Desktop.
Format json data on the command line
# pipe any json into the command to the right of the pipe to format any valid json payload
echo '{"foo": "bar"}' | python -c "import sys, json;print json.dumps(json.loads(sys.stdin.read()), indent=4)"
# use the built-in tool to do the exact same thing
echo '{"foo": "bar"}' | python -m json.tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment