Last active
May 11, 2020 00:57
-
-
Save pwc3/849a6da2b20f6a1e8bc9c9288b143bf4 to your computer and use it in GitHub Desktop.
Pretty-Print JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import sys | |
import json | |
try: | |
json.dump(json.load(sys.stdin), sys.stdout, sort_keys=True, indent=4) | |
except ValueError as err: | |
print("Error:", err, file=sys.stderr) | |
exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pretty-prints JSON via the terminal. Reads input only from stdin.
To format JSON on the clipboard:
To format JSON in a file: