JSON Formatter

Paste JSON to beautify, minify or validate it — with the exact line and column of any syntax error and a collapsible tree to explore it.

Free, no sign-upRuns in your browserUpdated November 2026
Output
Valid JSON
Input size
—
Output size
—
Keys
—
Max depth
—

Your JSON is parsed locally in this browser tab. Nothing is uploaded, logged or stored.

How to use the JSON Formatter

  1. Paste your JSON into the Input box, drop in a file with Open file, or click Sample to try it.
  2. Choose Beautify (2 spaces, 4 spaces or tabs) or Minify. The output updates as you type.
  3. If the JSON is invalid, read the exact line and column of the problem and click Jump to error to select it.
  4. Switch the output to Tree to explore nested objects, and tick Sort keys for a stable, diff-friendly order.
  5. Copy the result or download it as a .json file.

What a JSON formatter does

JSON (JavaScript Object Notation, standardised as RFC 8259 and ECMA-404) is the default data format for web APIs, configuration files and logs. Machines are happy with it on a single line, but people are not: a 40 KB API response with no line breaks is unreadable. A formatter parses the text into a data structure and prints it again with consistent indentation, one key per line, so you can scan it, review it and spot mistakes.

This tool does three jobs at once. It validates the input against the JSON grammar, beautifies or minifies it, and gives you a tree view for exploring deep structures. Parsing happens in your browser with the built-in JSON.parse, so API keys, customer records or tokens inside your payload never leave your device.

Beautify vs minify

ModeOutputUse it for
Beautify (2 spaces)Indented, one value per lineReading, code review, committing config files
Beautify (4 spaces / tab)Wider indentationMatching a project style guide or editor setting
MinifyAll insignificant whitespace removedSending over the network, embedding in env vars or HTML

Whitespace between tokens has no meaning in JSON, so formatting never changes the data. The stats panel shows the exact effect: switch between modes and compare the input and output sizes. On deeply nested API responses, removing indentation commonly saves a quarter or more of the bytes before compression.

The most common JSON errors (and how to fix them)

JSON is stricter than JavaScript object literals. When validation fails, this tool reports the exact line and column and shows the offending line with a caret under the problem. These are the mistakes it catches most often:

  • Trailing commas — [1, 2, 3,] or {"a": 1,} are valid in JavaScript but not in JSON. Delete the last comma.
  • Single quotes — strings and property names must use double quotes: {"name": "Ada"}, never {'name': 'Ada'}.
  • Unquoted keys — {name: "Ada"} is a JavaScript literal, not JSON.
  • Comments — // and /* */ are not allowed. If your file has them, it is probably JSONC or JSON5 (used by some editors and tsconfig files).
  • Raw line breaks inside strings — a newline in a string must be written as \n.
  • Special values — undefined, NaN, Infinity and functions do not exist in JSON. Use null or a string instead.
  • Leading zeros and hex — 007 and 0xFF are invalid numbers; write 7 and 255.

Worked example

Suppose an API returns {"id":42,"tags":["a","b",],"ok":true}. The validator stops at line 1, column 26 with "Trailing comma before ]", because after the comma following "b" it expected another value but found a closing bracket. Remove that comma and the formatter prints:

{
  "id": 42,
  "tags": [
    "a",
    "b"
  ],
  "ok": true
}

The stats panel then reports 3 keys, a maximum depth of 2 (the object and the array inside it) and the output size compared with the input.

Sorting keys for clean diffs

JSON objects are unordered by specification, but serializers usually keep insertion order, so two equivalent documents can look very different in a diff. Ticking Sort keys A–Z sorts every object recursively (arrays keep their order, because array order is meaningful). Format both files this way and paste them into the diff checker to see only the real changes.

Large numbers lose precision

JavaScript stores every number as a 64-bit float, so integers above 253 − 1 (9,007,199,254,740,991) are rounded when parsed. Database IDs such as Twitter/X snowflakes or 64-bit counters are the usual victims. This tool warns you when an integer in your input is too large to survive a round trip; the safest fix is to send such IDs as strings.

Tips

  • Need a spreadsheet instead? Convert an array of objects with the JSON to CSV converter.
  • Decoding a token? The payload of a JWT is Base64URL-encoded JSON — paste the middle part of the token into the Base64 decoder to read it.
  • JSON embedded in a query string must be percent-encoded first; the URL encoder handles that.

Frequently asked questions

Is it safe to paste sensitive JSON here?
Yes. Formatting and validation run entirely in your browser using JavaScript's built-in JSON parser. The data is never sent to a server and is not saved; closing the tab discards it. As a general habit, still avoid pasting live production secrets into any website you do not control.
Why does my JSON say "Unexpected token"?
The parser found a character it did not expect at that position. The usual causes are a trailing comma, a missing comma between items, single quotes, unquoted property names or a comment. The error message here gives the line and column and shows a caret under the exact character.
Does formatting change my data?
No. Whitespace outside strings has no meaning in JSON, so beautifying or minifying produces an equivalent document. The only exceptions are integers larger than 2^53, which JavaScript rounds when parsing — the tool warns you when that happens. Sorting keys changes only the order of keys, not their values.
Can I format JSON with comments (JSONC) or JSON5?
Not directly, because comments, trailing commas and single quotes are not part of standard JSON. Remove the comments first. The validator points to each one so you can delete them quickly.
How large a file can I format?
Files of several megabytes format comfortably in a modern browser. The tree view shows the first 4,000 nodes to stay responsive; the text output always contains the full document.
What is the difference between JSON and a JavaScript object?
JSON is a text format with a strict subset of JavaScript syntax: double-quoted keys and strings only, no comments, no trailing commas, and only strings, numbers, booleans, null, arrays and objects as values. A JavaScript object can hold functions, undefined, dates and other types that JSON cannot represent.

Last reviewed November 2026. Results are estimates for information only — see our disclaimer.