JSON Formatter

Format, validate and minify JSON — entirely in your browser.

Runs in your browser — nothing is uploaded

 

What a JSON formatter does

JSON travels best minified: one long line with no spaces. That is ideal for a network payload and hopeless for a person trying to read an API response, a config file or a log entry. A JSON formatter (or beautifier) re-indents the document so every object and array sits on its own lines, nested two spaces per level. It parses the document and writes it back out, so two edge cases change: integers beyond 2^53 lose precision (9007199254740993 becomes 9007199254740992), and if an object repeats a key only the last value is kept.

This formatter also validates as it goes. If the input is not valid JSON, you get the parser's error message with the line and column where it gave up, instead of silently reformatted garbage. Switch to Minify to go the other way and strip every insignificant space and line break.

Common reasons JSON fails to parse

Most invalid JSON comes from writing it by hand or copying it out of JavaScript. JSON is stricter than a JavaScript object literal: property names and strings must use double quotes, trailing commas after the last item are not allowed, and comments are not part of the format at all.

Other frequent culprits are the literal values undefined and NaN, which have no JSON equivalent, and unescaped control characters such as a raw tab or newline inside a string. If the error points at a position, look just before it: the parser usually stops one token after the real mistake.

Private by design

Many online JSON tools post your document to a server to format it. That is a poor fit for API responses that carry tokens, customer records or internal configuration. Here the formatting runs in your browser with the built-in JSON parser, so the text you paste is never uploaded, logged or stored.

Examples

Beautify a minified API response

Input

{"name":"Ada","languages":["en","fr"],"active":true,"manager":null}

Output

{
  "name": "Ada",
  "languages": [
    "en",
    "fr"
  ],
  "active": true,
  "manager": null
}
Minify a document for a request body

Input

{
  "id": 42,
  "tags": [
    "api",
    "v2"
  ]
}

Output

{"id":42,"tags":["api","v2"]}

How to use

  1. Paste or type your JSON into the input box.
  2. Pick an indent width, or choose Minify.
  3. Copy the formatted result.

FAQ

Is my JSON uploaded to a server?

No. The JSON Formatter runs entirely in your browser — your data never leaves your device.

Can it minify JSON as well as beautify it?

Yes. Switch to Minify to strip all insignificant whitespace and produce the smallest valid JSON.

Why does my JSON say it is invalid when it works in JavaScript?

JavaScript object literals allow single quotes, unquoted keys, trailing commas and comments. JSON allows none of these. Convert single quotes to double quotes, quote every key, and remove trailing commas and comments.

Is there a size limit?

There is no fixed limit; the practical ceiling is your browser's memory. Documents of several megabytes format in well under a second on a typical laptop.

Related tools