Beautify JSON in Emacs
Not completely sure where I found this, but I've had this in my .emacs
for a while now:
(defun beautify-json ()
(interactive)
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max))))
(shell-command-on-region b e
"python -mjson.tool" (current-buffer) t)))
Just run M-x beautify-json
on a buffer and it will reformat it.
Written by Stefan Arentz
Related protips
3 Responses
it relies on python ...
over 1 year ago
·
@cnwggu Pure emacs lisp version -> https://coderwall.com/p/w3qvba
over 1 year ago
·
@gongo thank u very much
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Emacs
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#