JSON Formatter
Beautify, minify, and validate your JSON data. Paste your JSON below and click Format.
At a glance
- Format — re-indent any JSON with consistent 2-space indentation.
- Minify — strip every unnecessary byte for transport and storage.
- Validate — parse check with the browser's real JSON parser and the exact error position.
- Copy — one-click copy of the formatted or minified result.
- Runs entirely in your browser — no upload, no signup, no limits.
Why format JSON at all?
JSON parsers do not care about whitespace — {"a":1,"b":2} and a beautifully indented version are the same data. The formatting is for the human on the other side of the screen: matching braces by eye, spotting which array element is malformed, and reading nested API responses without a syntax highlighter. That is why most developer workflows keep two forms of the same document: minified for the wire (API request bodies, cached config, stored blobs) and formatted for the desk (debugging a response, reviewing a package.json or tsconfig.json, comparing data before an edit).
This tool does both directions and validates in between. Paste anything, hit Format or Minify, and if the input is broken you get the parser's actual error message with its position — not a vague "something is wrong". When the data turns out to be a table you need in a spreadsheet, send it straight to the JSON to CSV converter.
Common JSON errors and how to fix them
"Unexpected token '<'"
You pasted HTML, not JSON — typically an error page returned by an API instead of the data you expected. Look at what your source actually returned before re-pasting.
"Unexpected token '''"
JSON strings and property names accept only double quotes. Single quotes are valid in JavaScript object literals but not in JSON. Swap them, and remember to escape any inner double quotes with a backslash.
"Unexpected token '}'" after a comma
A trailing comma: {"a":1,} is legal JavaScript but illegal JSON. Delete the comma before the closing brace or bracket.
"Unexpected end of JSON input"
The text stops mid-structure — an unclosed } or ] at the end, usually from an incomplete copy or a truncated log line. Count your brackets; this tool's Validate button will point at where parsing stopped.
"Unexpected token n / property names must be double-quoted"
Unquoted keys like {name: "x"} come from JavaScript source code, not JSON data. Quote every property name.
Frequently asked questions
What is JSON formatting?
JSON formatting (also called beautifying or pretty-printing) adds proper indentation and line breaks to JSON data, making it easier to read and debug.
What is JSON minification?
Minification removes all unnecessary whitespace from JSON, reducing its size for faster transmission. It is the inverse of formatting: the same data, stripped to the fewest bytes. Formatting is for humans, minification is for the wire.
Why do I get an "Unexpected token" error?
The parser hit a character that cannot start a JSON value at that position. The most common causes: pasted HTML instead of JSON (Unexpected token '<'), single quotes around strings or keys (JSON only allows double quotes), unquoted property names such as {name: "x"}, or trailing commas before a closing brace, which JavaScript object literals allow but the JSON specification does not.
Why do I get "Unexpected end of JSON input"?
The JSON text stops before every opened bracket and brace is closed — usually the input was truncated while copying from a terminal, log file or API response. Check the end of your input for a missing } or ].
Does JSON allow trailing commas or single quotes?
No to both. The JSON specification (RFC 8259) requires double-quoted strings and property names, and forbids a comma after the last member of an object or array. These constructs are legal in JavaScript object literals, which is why code copied from a .js file often fails to parse as JSON.
Is there a size limit for the JSON I format?
There is no upload limit because nothing is uploaded — formatting runs locally in your browser. Files of a few megabytes format without problems; for very large files (tens of megabytes or more) a command-line tool such as jq will be faster than any browser textarea.
When should I minify JSON instead of formatting it?
Minify for storage and transport: request bodies sent to APIs, cached config, or data written where every byte counts. Format for anything a human will read: debugging an API response, inspecting a config file, or reviewing data before editing it.
Is my data sent to a server?
No. Your JSON is processed entirely in your browser. Nothing is uploaded.