How do I format JSON? Three approaches (online / CLI / editor plugin)
When an API returns unreadable JSON, or a config file looks misaligned — format it first so you can actually see the structure.
The scenario
During integration work the API response is squeezed onto one line and finding a field by eye is painful. What you need is not another language to learn but a way to format the JSON into something readable, and to confirm that it is valid.
Three approaches
- An online tool (recommended): open the JSON formatter and paste.
- Your IDE: select the text in VS Code and run Format Document.
- The command line:
jq .fits nicely into a script pipeline.
Steps online
- Open the JSON formatter
- Paste the JSON and pick 2 / 4 / Tab indentation
- When you need a smaller payload, turn on "Minify output" and copy
Common questions
- Trailing commas and single quotes both break standard JSON parsing.
- UTF-8 text can be pasted as it is.
Wrapping up
Formatting is the first step of debugging. Use Base64 afterwards when you need to handle transport encoding.