Skip to content

Instantly share code, notes, and snippets.

@InFog
Last active August 29, 2015 14:23
Show Gist options
  • Save InFog/9465e2cf36c3765f4be7 to your computer and use it in GitHub Desktop.
Save InFog/9465e2cf36c3765f4be7 to your computer and use it in GitHub Desktop.
Format JSON in your clipboarb
#!/usr/bin/env python3
from tkinter import Tk
from json import dumps, loads
def show_json_from_clipboard():
t = Tk()
t.withdraw()
try:
json = loads(t.clipboard_get())
except:
print("There is no valid JSON in your clipboard")
return 1
print(dumps(json, indent=4, sort_keys=True))
return 0
if __name__ == '__main__':
exit(show_json_from_clipboard())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment