Skip to content

JSON Formatter

Format, beautify and minify JSON with clear error messages, key sorting and a tree view. Runs entirely in your browser: your data is never uploaded.

Result format

Paste JSON, open a file, or load an example to get started. Validation runs as you type.

Processed locally in your browser. Your data never leaves your device.

About this JSON formatter

Paste JSON to get a clean, indented version, a compact minified version, or a collapsible tree. The same editor validates as you type, so a syntax error is reported with its line and column the moment it appears. Everything happens locally in your browser tab.

How to use it

  1. Paste JSON into the input, drop a .json file onto it, choose Open file, or load an example.
  2. Pick an indent of 2 spaces, 4 spaces or a tab, and optionally sort object keys A to Z or Z to A.
  3. Switch between Formatted, Minified and Tree in the result panel.
  4. Copy or download the result, or use it as the new input to keep transforming it.

Example

Compact input:

{"user":{"id":7,"name":"Ada","roles":["admin","editor"]},"active":true}

Formatted with 2 spaces:

{
  "user": {
    "id": 7,
    "name": "Ada",
    "roles": [
      "admin",
      "editor"
    ]
  },
  "active": true
}

What formatting does and does not change

Formatting changes whitespace only. Numbers, string escapes, key order and even duplicate keys are kept exactly as you wrote them. This matters because the common shortcut, JSON.stringify(JSON.parse(text), null, 2), quietly rewrites your data: it turns 12345678901234567890 into 12345678901234567000, drops all but the last of several duplicate keys, and rewrites 1.10 as 1.1. Here, an integer that JavaScript cannot represent exactly is kept intact and flagged as a warning, so you know a JavaScript program reading it would round it.

Common problems

  • Trailing comma after the last item or property. JSON forbids it, unlike JavaScript.
  • Single quotes around strings or keys. JSON requires double quotes.
  • Comments. JSON has none. Strip them or use a JSONC-aware tool first.
  • Several documents in one file (JSON Lines). Format one line at a time, or wrap them in an array.

For a detailed explanation of each error and how it is reported, see the JSON Validator, and use the JSON Viewer to explore a large document without scrolling through it.

Frequently asked questions

Is my JSON uploaded anywhere?
No. Formatting, validation and the tree view all run in your browser. Nothing you paste or open is sent to a server, stored, or logged.
How large a document can it handle?
Up to 10 MB. Documents over 256 KB are processed in a background thread so the page stays responsive, results update live up to 2 MB, and larger documents run when you press Run.
Does sorting keys change the meaning of my JSON?
No. Objects are unordered in the JSON specification, so sorting keys changes only their order in the text. Array order is never changed.
Can it repair invalid JSON?
It does not guess. It tells you the exact line and column of the first problem and how to fix it, so the result is always what you intended. Trailing commas, single quotes and comments are the usual culprits.
Why are my numbers unchanged, for example 1.10 stays 1.10?
The formatter changes only whitespace. Numbers and strings are written exactly as they appear in your input, so nothing is rounded or re-encoded.