JSON Formatter & Validator - Beautify, Minify & Check JSON

Paste raw JSON to pretty-print it with your preferred indentation, minify it for production, or validate it with a precise error location.

The formatter parses your text with the browser's native JSON engine, so what passes here is exactly what JSON.parse accepts. Everything runs locally — nothing is uploaded.

JSON Formatter & Validator - Beautify, Minify & Check JSON
Paste raw JSON to pretty-print it with your preferred indentation, minify it for production, or validate it with a precise error location.

Privacy: your data never leaves the browser. Parsing, formatting, and validation all happen on your device.

How it works: the input is parsed with JSON.parse and re-serialized with JSON.stringify using your chosen indentation (or none for minify).

About the JSON formatter and validator

JSON (JavaScript Object Notation) is the lingua franca of modern APIs, configuration files, log pipelines, and data exchange. It is easy for machines to produce but often painful for humans to read: an API response usually arrives as a single minified line thousands of characters long, and a hand-edited config file fails to load because of one missing comma. This JSON formatter solves both problems in one place — it beautifies compact JSON into an indented, readable structure, compresses pretty JSON back into the smallest possible form, and checks any input for syntax errors with a precise line and column location. The tool is deliberately built on the browser's native JSON engine rather than a custom parser. When you click Format, Minify, or Validate, your text goes through JSON.parse, the same implementation your JavaScript code uses at runtime. That means the validator's verdict is authoritative: if it parses here, it parses in Node.js and every modern browser, and if it fails here you get the engine's own error message, translated into a line and column so you can jump straight to the problem. Common culprits include trailing commas, single quotes instead of double quotes, unquoted property names, comments (which standard JSON does not allow), and stray control characters from copy-pasting out of terminals. Formatting options cover the styles used in real projects: two-space indentation (the default in most JavaScript ecosystems), four spaces, or tab characters. The optional key sorting pass recursively rewrites every object with its properties in alphabetical order, which is invaluable when you need to diff two payloads or keep configuration files in a canonical order — note that it changes key order only, never values, and JSON semantics do not depend on key order. After a successful operation the tool also reports quick statistics: the number of top-level keys (or array elements) and the exact size of the result in bytes, handy when you are watching payload budgets or size limits on request bodies. Minification is the reverse of beautifying: all insignificant whitespace is stripped, producing the most compact equivalent document. Use it before embedding JSON in environment variables, query strings, or bandwidth-sensitive API calls. Everything happens locally in your browser tab. The text you paste is never transmitted to a server, stored, or logged, which makes the tool safe for private payloads such as tokens, customer records, or internal configuration. Limitations worth knowing: extremely large documents (hundreds of megabytes) are constrained by browser memory, and formats that extend JSON — JSON5, JSONC with comments, or NDJSON streams — must be converted to strict JSON before they will validate.

JSON formatter examples

Typical inputs and what each action produces.

InputAction & outputNote
{"name":"Ada","tags":["math","code"]}Format → indented across multiple lines with your chosen indentationGreat for reading minified API responses.
A pretty-printed config file of 40 linesMinify → one compact line with all whitespace removedSmallest equivalent document, ideal for env vars and request bodies.
{"id": 1, "name": "Ada",}Validate → error at line 1: trailing comma is not allowedStrict JSON forbids trailing commas, comments, and single quotes.
{"z":1,"m":2,"b":3} with key sorting enabledFormat → keys reordered to b, m, z at every nesting levelSorted keys make diffs between two payloads stable.

How to format and validate JSON

  1. Paste your JSON into the input box — a minified API response, a config file, or a hand-written snippet.
  2. Pick the indentation you want (2 spaces, 4 spaces, or tabs) and optionally enable alphabetical key sorting.
  3. Click Format for pretty output, Minify for the compact form, or Validate to only check the syntax.
  4. If parsing fails, read the error message and jump to the reported line and column to fix the problem.
  5. Copy the output from the result panel; the byte size shown helps you track payload limits.

JSON formatter FAQ

Why does my JSON fail to validate?
The most common causes are trailing commas, single quotes around strings or keys, unquoted property names, comments, and unescaped control characters. Strict JSON allows none of these. The error message includes the line and column where the parser gave up, which is usually at or just after the offending character.
Is it safe to paste sensitive data here?
Yes. The formatter runs entirely in your browser using the native JSON engine — nothing you paste is sent over the network, stored, or logged. You can disconnect from the internet after loading the page and it will keep working.
Does minifying change my data?
No. Minification removes only insignificant whitespace between tokens; every value, string, and number stays byte-for-byte identical in meaning. Parsing the minified output yields exactly the same data structure as the original.
What does the sort-keys option do?
It recursively rewrites every object so its properties appear in alphabetical order, at all nesting depths. Values and arrays are untouched. Since JSON object key order carries no meaning, sorting is a safe way to get canonical output for diffing and version control.
What do the key count and byte size mean?
The key count is the number of properties on the top-level object (or elements if the root is an array). The byte size is the UTF-8 encoded length of the result, which is what matters for HTTP payload limits, not the character count.
Can I format JSON5 or files with comments?
Not directly. This tool validates strict JSON as defined by RFC 8259, and comments or JSON5 conveniences like unquoted keys will be reported as errors. Strip the comments or convert the file to strict JSON first, then format it here.