4

Given a file with a large JSON object all on one line like

{"versions":[{"count":2,"version":""},{"count":1,"version":"1.1.1"},{"count":14,"version":"2.9"},{...

How can I format this to be human readable in Vim?

7

This one-liner works well to format JSON in Vim into a human readable form:

:%!python -m json.tool

4

Or you can install jq which is faster (written in C) from your package manager or from source and then in vim, type :

:%!jq .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.