JSON Formatter

Pretty-print, validate, beautify, minify, and explore JSON as a collapsible tree — all in one place. Everything runs in your browser via the native JSON.parse(), so your data is never uploaded and the tool works offline.

Input JSON
Formatted Output
Formatted JSON will appear here...

Ctrl+Enter to format

🌳 JSON Tree View

Format JSON to see the tree view...

Quick answer

A JSON formatter pretty-prints minified or messy JSON by adding consistent indentation and line breaks so it's readable. JSON Dev Tools formats your JSON entirely in your browser using JSON.parse() and JSON.stringify() — your data is never uploaded to a server. Paste JSON, click Format, and read or copy the result.

Key takeaways

How the JSON Formatter Works

When to Use the JSON Formatter

Worked example: formatting and repairing

This input isn't valid JSON — it uses single quotes, an unquoted key, and a trailing comma, the way a JavaScript object literal might. Clicking Repair fixes those, and formatting then lays it out:

Input (almost JSON)

{
  name: 'Alice',
  roles: ['admin', 'editor'],
}

Output (repaired & formatted)

{
  "name": "Alice",
  "roles": [
    "admin",
    "editor"
  ]
}

What happened

Edge cases & gotchas

Frequently Asked Questions

What does formatting JSON do?

JSON formatting adds indentation and line breaks so nested objects and arrays become easy to read. The data itself does not change — only the whitespace presentation does.

Can I use this tool for API responses?

Yes. Paste any API JSON response and click Format to inspect its structure, keys, and values. The tree view below the editor lets you expand and collapse nested objects interactively.

Is my JSON sent to a server?

No. All formatting, validation, and tree rendering happens entirely in your browser using JavaScript. Your data never leaves your device.

What is the difference between JSON Formatter and JSON Validator?

A formatter adds indentation to make JSON readable — it requires valid JSON first. A validator checks whether JSON is syntactically correct and reports errors. This tool does both: it validates as part of the format step and surfaces any errors before formatting.

Can I choose 4-space indentation?

Yes. Use the indentation selector in the toolbar to switch between 2-space, 4-space, and tab indentation before clicking Format.

What can the Repair button fix?

Repair fixes the common mistakes that stop JSON from parsing: single-quoted strings become double-quoted, unquoted object keys get quotes added, trailing commas are removed, and JavaScript-style comments are stripped. It's for input that is nearly JSON but not quite — once repaired, the result is formatted normally. It cannot invent missing data, so a truncated or structurally broken document may still need a manual fix.