JSON Formatter & Validator

Minified JSON is a wall of text. One missing brace in an API response, a config file or a webhook payload and you are counting quotation marks by eye. This formatter re-indents JSON so the structure is obvious, and when the document will not parse it tells you the exact position the parser gave up at.

Everything happens inside the page using the browser's own JSON.parse. Nothing is uploaded, which matters when the payload you are debugging contains an access token or a customer record.

Free · runs in your browser · updated

Input Raw JSON
Tab Size
Validated Output

JSON Formatter & Validator at a glance

What it does
Paste messy JSON and get readable, indented output with the exact line and character of any syntax error.
Where it runs
Entirely in your browser — no data is uploaded
Works offline
Yes, once the page has loaded
Cost
Free, with no account and no usage limit

How to use the JSON formatter

  1. Paste your JSON into the input box. Full API responses, a fragment, a package.json, a log line - anything that should be valid JSON.
  2. Pick an indent style. Two spaces is the JavaScript and npm convention, four spaces is common in Python and Java codebases, tabs suit teams who let each developer choose a width.
  3. Press Beautify to expand the document, or Minify to strip every optional space and newline for the smallest possible payload.
  4. Read the validation line. Valid JSON reports the parsed size; invalid JSON reports the parser's error message and the character offset it stopped at.
  5. Copy the result with one click, or clear the box and start again.

The JSON errors people actually hit

JSON is a deliberately small format, and almost every real-world failure comes from writing it as though it were JavaScript. These are the ones worth recognising on sight.

Error messageUsual cause
Unexpected token }A trailing comma after the last item of an object or array. JavaScript allows it, JSON does not.
Unexpected token 'Single-quoted strings. JSON strings must use double quotes, and so must every key.
Unexpected token NA raw NaN, Infinity or undefined. None of the three exist in JSON - use null or a string.
Unexpected end of JSON inputThe document is truncated. Often a response that was cut off, or a copy-paste that missed the closing brace.
Unexpected token <You are not looking at JSON at all - the server returned an HTML error page. Check the status code.
Bad control characterA literal newline or tab inside a string. These must be escaped as \n and \t.

Comments are the other frequent surprise. Neither // nor /* */ is legal JSON, even though editors happily accept them in tsconfig.json and similar files - those use JSONC, a superset, and a strict parser will reject them.

When to minify and when to keep it readable

Whitespace in JSON is free to the parser and expensive on the wire. Minifying a typical API response removes 15-30% of its bytes before compression, and gzip narrows the gap further, so the practical rule is simple.

  • Minify anything crossing a network - API responses, request bodies, values pushed into a cache or a message queue.
  • Keep files people edit indented - configuration, fixtures, seed data. A readable diff is worth far more than the bytes.
  • Indent anything committed to git. A minified file changes on one enormous line, so every edit looks like a full rewrite in code review.

A short refresher on the format

JSON has exactly six value types: object, array, string, number, boolean and null. There is no date type, which is why timestamps travel as ISO 8601 strings such as "2026-09-09T14:30:00Z". There is no integer type either - every number is a double, so identifiers beyond 253 lose precision and should be sent as strings. Large database IDs and financial amounts in particular are safer as strings.

Key order is not guaranteed to be meaningful, and duplicate keys are undefined behaviour: most parsers keep the last one silently. If ordering matters to your data, use an array.

Debugging a payload with secrets in it? This page never sends your input anywhere. The formatting runs in JavaScript on your own machine, so a bearer token pasted here does not leave the browser.

Frequently asked questions

No. The tool calls the browser's built-in JSON.parse and JSON.stringify on your device. No request is made and nothing is stored, so you can safely paste responses that contain tokens or personal data.

Standard JSON has no comment syntax. Files like tsconfig.json and devcontainer.json use JSONC, a Microsoft superset that permits // and trailing commas. Strip the comments before validating, or expect the error.

It is limited by your browser's memory rather than any upload cap. Documents of a few megabytes format instantly; tens of megabytes will work but the textarea itself becomes slow to scroll. For very large files a command-line tool such as jq is a better fit.

Beautifying and minifying only change whitespace. One caveat: because the document is parsed and re-serialised, numbers are normalised to their double representation, so 1.10 comes back as 1.1 and very large integers may lose their final digits.

Validation asks whether the syntax parses at all. Linting - against a JSON Schema, for instance - asks whether the parsed data has the fields and types your application expects. This tool does the first.

Nothing you enter here leaves your browser

JSON Formatter & Validator does its work in JavaScript running on your own device. The page loads once, and after that there is no upload step and no server involved — which matters here because API responses, tokens and configuration files are exactly the kind of thing that should not be posted to someone else’s server for formatting.

You can verify this rather than taking our word for it: load the page, disconnect from the internet, and the tool keeps working. Our privacy policy sets out what is and is not collected, and this guide explains why the distinction matters.