JSON Formatter

Pretty-print, validate and minify JSON.

Runs locallyYour input is processed in this tab. The editor blocks outgoing network requests.
JSON input

The JSON Formatter pretty-prints minified or messy JSON with consistent indentation, checks it as you type and points to the exact line and column of any syntax error. It is built for developers reading API responses, logs and config files. Everything runs in your browser, inside an isolated frame that blocks network requests — nothing is uploaded.

How to format JSON

  1. Paste JSON into the input pane, drop a .json file on it, or press ⌘/Ctrl O to open one. Pasted text is formatted straight away; press ⌘/Ctrl Enter to format again after editing.
  2. Pick an Indent (2 spaces, 4 spaces or a tab) and switch on Sort keys or Inline short arrays if you want a more compact, diff-friendly layout. Use the Minify or Validate mode when you need a single line or only a yes/no answer.
  3. Copy the result with ⌥/Alt C, download it with ⌘/Ctrl S, or choose a Next action — Minify, Sort keys, convert it to YAML, flatten an array of records to CSV or escape it as a string.

Examples

Minified API response

A single-line response body, as it comes back from curl or a network log, formatted with the default 2-space indent.

JSON
{"id":1042,"status":"active","user":{"name":"Asha Rao","roles":["admin","editor"]},"tags":[]}

Result:

JSON
{
  "id": 1042,
  "status": "active",
  "user": {
    "name": "Asha Rao",
    "roles": [
      "admin",
      "editor"
    ]
  },
  "tags": []
}

Sorted keys, 4-space indent, inline arrays

The same input with Indent set to 4 spaces and both Sort keys and Inline short arrays on. Sorted output makes two payloads easy to compare line by line.

JSON
{"id":1042,"status":"active","user":{"name":"Asha Rao","roles":["admin","editor"]},"tags":[]}

Result:

JSON
{
    "id": 1042,
    "status": "active",
    "tags": [],
    "user": {
        "name": "Asha Rao",
        "roles": ["admin", "editor"]
    }
}

Config file with comments and trailing commas

A JSONC-style settings file. With Allow comments & trailing commas on, the formatter strips them and reports "Removed 2 comments and 2 trailing commas."

JSON
{
  // service name
  "name": "api",
  "port": 8080, /* default */
  "hosts": ["a.internal", "b.internal",],
}

Result:

JSON
{
  "name": "api",
  "port": 8080,
  "hosts": [
    "a.internal",
    "b.internal"
  ]
}

Options explained

  • Indent — the whitespace used for each nesting level: 2 spaces, 4 spaces or a tab.
  • Sort keys — orders object keys alphabetically at every depth; array order is never changed.
  • Escape non-ASCII — writes characters outside ASCII, such as ü or ₹, as \uXXXX escapes for systems that only accept 7-bit text.
  • Inline short arrays — keeps arrays of up to twelve short primitive values on one line instead of one item per line.
  • Allow comments & trailing commas — accepts JSON5/JSONC-style input by removing // and /* */ comments and trailing commas before parsing, and tells you how many it removed.

Common JSON errors and how to fix them

When the input is invalid, the output pane shows the error with its line and column, plus a likely cause. Press F8 to jump to it.

Trailing comma after the last item

Unexpected ']' or Unexpected '}' with the hint "trailing comma after the last item on line N" means a comma sits before a closing bracket. Delete it, or turn on Allow comments & trailing commas.

"This looks like a JavaScript object, not JSON"

Unquoted keys combined with single-quoted strings usually mean an object literal copied from source code. JSON needs double quotes around every key and string. The JSON Validator can rewrite the quotes for you.

Smart (curly) quotes

Text pasted from a word processor or chat app often contains “ and ” instead of straight quotes. Replace them with ".

Comments are not allowed

Standard JSON has no comment syntax, so // or /* triggers an error. Remove the comment, or use the Try lenient mode action.

Missing comma between items

The hint "missing comma between items (after line N)" appears when one value ends and the next begins with nothing between them — typically after deleting or reordering lines.

NaN, Infinity, undefined, True or None

These are JavaScript or Python values, not JSON. Use null or a number in place of NaN, Infinity and undefined, and lowercase true, false and null.

Byte-order mark at the start

Some Windows editors save an invisible BOM at the start of the file, which strict parsers reject at line 1, column 1. Lenient mode removes it; saving the file as "UTF-8 without BOM" fixes it at the source.

Input ends before the object closes

"Was it cut off?" means brackets are still open at the end of the input. Log viewers and terminals often truncate long lines, so copy the full value again.

FAQ

Is it safe to paste API responses here?

Yes. Formatting runs entirely in your browser, and the editor lives in an isolated frame that blocks network requests, so tokens, customer records and internal payloads never leave your device. Nothing is stored on a server. Your settings are remembered on this device; the input itself is only kept if you turn on "Remember my last input".

What is the difference between beautify, prettify and pretty-print?

They all describe the same job: adding line breaks and indentation so nested JSON is readable. This page does all three. If you need the opposite — removing whitespace to shrink a payload — use Minify mode or the dedicated JSON Minifier, which also reports how much smaller the result is.

Does formatting change my numbers or strings?

No. Values are printed exactly as they appear in the input, so 1.50 stays 1.50 and an ID such as 12345678901234567890 keeps every digit instead of being rounded. Strings keep their original escapes. Only whitespace changes, plus key order if you turn on Sort keys.

Can I format JSON that contains comments?

Yes. Turn on Allow comments & trailing commas to accept JSONC and JSON5-style files such as editor settings and tsconfig.json. The comments are removed in the output, because standard JSON cannot represent them, and a notice tells you how many comments and trailing commas were dropped.

How large a file can I format?

Files up to 50 MB can be opened. Inputs over roughly 200 KB are processed in a background worker so the page stays responsive while formatting. Very large single-line files are often faster to inspect after formatting, since the editor can then scroll and fold them line by line.

Why is the key order different from what my API returned?

It is not, unless Sort keys is on. The formatter keeps keys in their original order by default. Some tools and languages reorder object keys when they parse JSON, so a payload printed elsewhere may look different; this page prints the input as written.

How do I check JSON without reformatting it?

Switch to Validate mode, or open the JSON Validator. Validation parses the input with the same strict rules and reports the first error with its line, column and likely cause. The validator also offers a one-click fix for trailing commas, single quotes and unquoted keys.

After formatting, you can convert JSON to YAML for a Kubernetes or CI config, turn an array of records into CSV for a spreadsheet, or produce XML for a legacy integration. The common JSON errors guide explains each parser message in more depth, and the data tools category lists every converter.

Browse all Data Formatters & Converters

Guides