← Back to all posts

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

  1. An online tool (recommended): open the JSON formatter and paste.
  2. Your IDE: select the text in VS Code and run Format Document.
  3. The command line: jq . fits nicely into a script pipeline.

Steps online

  1. Open the JSON formatter
  2. Paste the JSON and pick 2 / 4 / Tab indentation
  3. 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.