Skip to content

Instantly share code, notes, and snippets.

@KyleJamesWalker
Created December 29, 2017 23:07
Show Gist options
  • Save KyleJamesWalker/071158233fc82eaf0d8a1f9e273c716c to your computer and use it in GitHub Desktop.
Save KyleJamesWalker/071158233fc82eaf0d8a1f9e273c716c to your computer and use it in GitHub Desktop.
Print a JSON file with color!
import json
from pygments import highlight, lexers, formatters
def pretty_json_file(fn):
print(highlight(
json.dumps(json.load(open(fn)), sort_keys=True, indent=2),
lexers.JsonLexer(),
formatters.TerminalFormatter(),
))
pretty_json_file('example.json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment