How to Format JSON Online: Step-by-Step (with Examples)

Paste, format, validate and copy JSON in seconds. A step-by-step guide to pretty-printing JSON with 2 spaces, 4 spaces or tabs.

Advertisement

Formatting JSON means adding consistent indentation and line breaks so the structure is easy to read. It takes seconds with an online formatter and requires no installation.

Step 1 — Paste your JSON

Copy JSON from an API response, log file or editor and paste it into the JSON formatter input. You can also drag a .json file into the editor or use the file picker on mobile.

Step 2 — Choose indentation

  • 2 spaces — the default; compact and common in JavaScript projects.
  • 4 spaces — roomier; popular in Python and Java tooling.
  • Tab — lets each reader set their own display width.

Step 3 — Press Format (Ctrl/⌘ + Enter)

Before:

{"name":"John","age":30,"active":true}

After (2 spaces):

{
  "name": "John",
  "age": 30,
  "active": true
}

Step 4 — Copy or download

Use Copy to put the result on your clipboard or Download to save data.json. The file is created in your browser — nothing is uploaded.

What if it says "Invalid JSON"?

Open the same input in the JSON validator to see the line and column, fix the issue (usually a missing comma or quote), and format again. Our common JSON errors guide covers the seven cases you will see most.

Tips for large files

  • Formatting runs locally; files up to several megabytes stay responsive thanks to a background worker.
  • For huge payloads, explore with the JSON tree viewer instead of reading raw text.
  • Keep a beautified copy for development and ship a minified copy to production.
Advertisement

Try it in the tools

Related guides

Advertisement