Skip to content

Instantly share code, notes, and snippets.

@mkropat
Created November 27, 2013 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkropat/7679386 to your computer and use it in GitHub Desktop.
Save mkropat/7679386 to your computer and use it in GitHub Desktop.
Pretty-print JSON data to the console
#!/usr/bin/env python
import json, sys
if len(sys.argv) < 2 or sys.argv[1] == '-':
f = sys.stdin
else:
f = open(sys.argv[1])
json.dump(json.load(f), sys.stdout, indent=4, separators=(',', ': '))
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment