JSON Formatter & Validator

Paste JSON to pretty-print it, minify it, or check whether it is valid. Everything runs in your browser and large documents are parsed in a background thread so the page never freezes.

Bytes: 0
Lines: 0

What this tool does

Formatting re-indents a JSON document with two spaces, four spaces or tabs so that nested objects and arrays are easy to read. Minifying does the opposite: it strips every byte of whitespace so the document is as small as possible for storage or transfer. Validation parses the document and reports the first error it finds, with the line and column so you can jump straight to it.

The input side is deliberately forgiving. It accepts JSON5, which means single-quoted strings, comments, trailing commas and unquoted keys are all understood. You choose whether the output is strict JSON or JSON5.

Common JSON errors it catches

  • Trailing commas after the last item in an object or array.
  • Single quotes around strings or keys, which JSON does not allow.
  • Unquoted keys, comments and other JavaScript-isms that are fine in JSON5 but not in JSON.
  • Missing or mismatched brackets and braces, usually caused by a copy-paste that cut off the end.
  • Control characters and bad escape sequences inside strings.

Large files

Documents above about one megabyte are parsed in a Web Worker so the page stays responsive, and syntax highlighting switches itself off past a few hundred kilobytes because it would cost more than it helps. The result can be downloaded as a file when it is too large to display comfortably.

Frequently asked questions

Is my JSON sent to a server?
No. The page is rendered on a server, but parsing, formatting and validation happen entirely in your browser. Nothing you paste leaves your machine.
What is the difference between formatting and minifying JSON?
Formatting adds indentation and line breaks so people can read the document. Minifying removes all optional whitespace so machines can transfer it in fewer bytes. Both produce the same data.
Why is my JSON invalid when it works in JavaScript?
JavaScript object literals allow single quotes, trailing commas, comments and unquoted keys. Strict JSON allows none of these. Switch the output to JSON to get a version that any parser accepts.
How large a file can it handle?
Multi-megabyte documents are fine. They are processed in a background thread and the output is truncated for display, with the full result available as a download.