JSON Formatter & Validator

Format, minify and validate JSON with clear error messages showing exactly where the syntax is wrong. Runs entirely in your browser.

  • Free — No signup required
  • Instant — Results update as you type
  • Private — Processed in your browser

JSON that arrives from an API, a log line or a config file is usually either minified into one unreadable line or hand-edited into something that no longer parses. This tool handles both directions with the parser built into your browser, which means the result is exactly what any JavaScript runtime would accept.

How it works

Paste JSON into the input. In Format mode the text is parsed with JSON.parse and re-serialised with JSON.stringify using the indent you chose (2 or 4 spaces). Minify does the same parse but serialises with no whitespace at all, which is what you want for an HTTP body or an environment variable. Either way the output is a fresh serialisation of the parsed value, not a whitespace edit of your text, so it is guaranteed valid.

If parsing fails you get the parser's own message. When the browser reports a character offset, the tool converts it to a line and column so you can jump straight to the fault. Chromium and Firefox report offsets; some other engines only describe the problem, in which case you see the message without a position.

Copy puts the result on the clipboard; Download saves it as data.json. Nothing is uploaded, and the tool keeps working offline once the page has loaded.

What re-serialising changes

Because the output is rebuilt from the parsed value, a few things are normalised, and it is worth knowing which:

  • Numbers are printed in their canonical JavaScript form: 1.0 becomes 1, 1e2 becomes 100, and integers beyond 2⁵³ lose precision. Do not round-trip 64-bit database IDs or financial amounts stored as large integers through any JavaScript formatter; keep them as strings.
  • Duplicate keys are collapsed; the last value wins, silently.
  • Escapes in strings are resolved. "\u00e9" comes back as "é", and "\/" becomes "/". The meaning is identical, the bytes are not.
  • Key order is preserved as written, except that integer-like keys such as "1" are moved to the front, because JavaScript objects order those keys numerically.

None of this changes what a consumer will read, but if you are diffing files or verifying a signature over the raw text, format a copy rather than the original.

Reading the error

The three faults behind most "unexpected token" messages are a trailing comma after the last item, single quotes instead of double quotes, and an unquoted key. JSON has no comments either; if you are pasting from a .jsonc or a JavaScript file, strip them first. A message about an unexpected end of input almost always means a bracket or brace was never closed; the reported position is the end of the text, so count your closers.

The same parse-then-print step is available on the command line with jq, which is handy for files too large to paste:

jq . response.json        # pretty-print with 2-space indent
jq -c . response.json     # minify to a single line

Learn more

Well-structured JSON is only half of a good API. Building REST APIs with Spring Boot shows how the server side serialises objects, handles nulls and dates, and returns error bodies that are themselves valid JSON, while REST API design covers naming, pagination and versioning so the payloads you format here are consistent to begin with. To decode the JSON inside a token, use the JWT decoder, which applies the same formatting to the header and payload.

FAQ

Is my JSON data sent to a server?
No. Formatting, minifying and validating all happen locally in your browser using the built-in JSON parser — your data never leaves your device.
What's the difference between formatting and minifying?
Formatting adds indentation and line breaks so JSON is easy to read. Minifying removes all unnecessary whitespace to produce the smallest possible output.
Why does it say my JSON is invalid?
The validator reports the exact line and column where parsing failed — common causes are trailing commas, unquoted keys, or single quotes instead of double quotes.