StokeBloke.com

Pretty Format Json in Emacs

To format json data in emacs, its best to use the python module ‘json.tool’. Simply make a function to wrap up the whole buffer and format it.

(defun json-format ()
  (interactive)
  (save-excursion
    (shell-command-on-region (point-min) (point-max) "python -m json.tool" (buffer-name) t)
    )
  )

Leave a Reply