Log in Sign Up

JSON Formatter & Validator

Beautify, minify, and validate JSON instantly in your browser.

About This Tool

The JSON Formatter beautifies messy JSON with clean indentation, minifies it to a single compact line, and validates the syntax with a clear error message and position when something is wrong. It is useful for inspecting API responses, config files, and data payloads.

Parsing runs entirely in your browser using the native JSON engine, so even large payloads stay private and process instantly.

  • check_circleBeautify JSON with 2-space indentation
  • check_circleMinify JSON to a single line
  • check_circleValidate syntax with error messages
  • check_circleRuns in your browser, nothing uploaded

Reading the error message a JSON parser gives you

JSON parse errors point at where the parser gave up, which is usually just after the real mistake. Four errors account for most of them. A trailing comma after the last item in an object or array is valid in JavaScript and invalid in JSON, so {"a": 1,} fails. Single quotes are not string delimiters in JSON; keys and string values both require double quotes. Unquoted keys are legal in JavaScript object literals and illegal in JSON. And unescaped control characters inside strings, most often a raw newline pasted from a text editor, break parsing mid-string.

If the error says something like "Unexpected token at position 428", format the document first. Once it is indented, the structure becomes visible and the offending line is usually within a few rows of where the nesting looks wrong.

Minify or pretty-print: choosing by destination

Formatted and minified JSON are the same data, so the choice is purely about who reads it next. Pretty-print with two-space indentation for anything a human will open: config files committed to a repository, fixtures, documentation examples, and API responses you are debugging. Indentation makes a diff readable, which matters more than file size in version control, because a minified JSON file changes as one enormous line on every edit.

Minify for anything crossing a network or embedded in a page. Whitespace is typically 15 to 30 percent of a formatted JSON payload, and stripping it reduces transfer size before compression even starts. API responses, browser localStorage values, and JSON embedded in HTML data attributes should all be minified. One exception: gzip compresses repeated whitespace extremely well, so on a gzip-enabled endpoint the real-world saving is smaller than the raw byte count suggests.

What JSON cannot represent

Several everyday values have no native JSON type, and knowing the substitutes prevents data loss. There is no date type, so dates travel as strings, and the only format that is unambiguous across time zones and locales is ISO 8601 (2026-08-14T11:30:00Z). Sending 14/08/2026 guarantees an American consumer will read it as a different day.

There is no integer type distinct from float, and JSON numbers are parsed as IEEE 754 doubles in JavaScript, which loses precision above 2^53. Database IDs, Twitter-style snowflake IDs, and currency amounts in the smallest unit should be sent as strings if they can exceed that. There is also no comment syntax; anything a parser sees that looks like // outside a string is an error, so use a dedicated description field instead. Finally, JSON has no undefined and no NaN or Infinity, so those become null or fail to serialise.

JavaScript object literal versus strict JSON

FeatureJavaScriptJSON
Single-quoted stringsAllowedInvalid
Unquoted keysAllowedInvalid
Trailing commaAllowedInvalid
CommentsAllowedInvalid
undefined, NaN, InfinityAllowedNo equivalent
Date objectsNative typeMust be an ISO 8601 string

Frequently Asked Questions

What does beautify do? expand_more

It re-indents your JSON with line breaks and spacing so the structure is easy to read.

Why does it say my JSON is invalid? expand_more

The validator uses a strict JSON parser. Common issues are trailing commas, single quotes instead of double quotes, and missing brackets. The error message points to the problem.

Is my data safe? expand_more

Yes. JSON is parsed in your browser and is never uploaded to a server.