JSON Formatter & Validator

Share:
Developer Tools

JSON Formatter & Validator

Format, validate and minify JSON instantly — with clear error messages and line numbers.

By Checked against sources by Last reviewed DEVELOPER FORMAT JSON VALIDATE
Your browser is too old for this tool’s interactive features. Please update to Safari 13.1, Chrome or Edge 80, Firefox 74 or newer.

JSON Formatter & Validator Tool

0 chars

Tab inserts an indent; press Esc, then Tab, to move on. Ctrl/⌘ + Enter formats.

📅 Research current as of 05 Nov 2026 · Sources: RFC 8259 (STD 90, December 2017) and ECMA-404 2nd edition for the JSON grammar the parser enforces, the duplicate-name rule, the interoperable number range, the byte order mark and the unpaired-surrogate warning; ECMA-262 for the JSON.parse behaviour the notes compare against
Standards, published formulas, and reference data are revised over time — check against a current authoritative source before relying on these figures.
Advertisement
After results · AD-W1 Responsive · Post-tool — peak engagement

How to Use the JSON Formatter

Paste your raw or minified JSON

Drop in any JSON string — from an API response, config file, or log output. The textarea accepts any valid or invalid JSON so errors can be detected and reported.

Choose your indent preference

Select 2 spaces, 4 spaces, or Tab to match your codebase style guide. The indent setting also applies when re-formatting — switch at any time and the output updates instantly.

Click Format to pretty-print and validate

The tool parses your JSON and highlights errors with exact positions. A green badge confirms valid JSON. A red error banner pinpoints exactly what went wrong so you can fix it immediately.

Copy or download the result

One-click copy to clipboard or download as a .json file ready to use in your project. Line numbers in the output make it easy to navigate large JSON documents.

Advertisement
After how-to · AD-W2 Responsive

JSON — The Language of Modern APIs

What this page does to your JSON

It changes the whitespace and nothing else. The page reads your text with its own strict RFC 8259 parser and lays the same tokens out again at the indent you chose: every string and every number is copied exactly as you typed it, every object member stays where it was, and a repeated name stays repeated. Minify and Format differ only in the whitespace between tokens, so either one turned back into the other gives you the same characters.

That is not how a formatter built on JavaScript's own JSON.parse and JSON.stringify behaves, and the difference is the reason this page lists notes under its output. A parse-and-stringify round trip passes your document through JavaScript values, and four things do not survive the trip:

Duplicate names collapse. RFC 8259 §4 says the names within an object SHOULD be unique and is explicit about what happens when they are not: the behavior of software that receives such an object is unpredictable. Many implementations report the last name/value pair only. Other implementations report an error or fail to parse the object, and some implementations report all of the name/value pairs, including duplicates. JSON.parse is in the first group: {"a":1,"a":2} becomes {"a":2} without a word. This page keeps both pairs and tells you where the second one is. Names are compared after their escapes are resolved, as §8.3 asks, so "a" and "a" count as the same name.

Large integers are rounded. JSON's grammar puts no bound on a number, but RFC 8259 §6 notes that integers in the range [-(2**53)+1, (2**53)-1] are interoperable in the sense that implementations will agree exactly on their numeric values, and JavaScript numbers are the IEEE 754 binary64 values that range describes. Through JSON.parse the 64-bit ID 12345678901234567890 becomes 12345678901234567000, a different number in valid JSON. Here it is kept digit for digit, and the note says what a binary64 reader would make of it. The RFC also names 1E400 as a magnitude that may indicate potential interoperability problems; a parse-and-stringify round trip turns it into null.

Integer-like names are reordered. RFC 8259 §4 observes that JSON parsing libraries have been observed to differ as to whether or not they make the ordering of object members visible to calling software. ECMAScript puts keys that look like array indices first, in numeric order, so a round trip writes {"10":"a","9":"b"} back as {"9":"b","10":"a"}. This page keeps the order you wrote.

Spellings are normalised. 1.0 becomes 1, 1E+2 becomes 100, -0 becomes 0, and an escape such as A or \/ is replaced by the character it names. These carry the same information, and RFC 8259 §7 allows both spellings of an escaped character, but they make a diff noisy. This page leaves them alone and does not note them.

Everything runs in the page. There is no upload step, no request carries what you format, validate or minify, and the Download button builds the file locally with the Blob API.

Why valid JSON is a narrower target than it looks

JSON's grammar is small enough to fit on a page, and its strictness surprises people arriving from JavaScript or Python, where the same text is legal. What this page rejects, it rejects because RFC 8259's ABNF has no production for it, and the error names the line and column of the first character that broke the rule. Show in input selects that character in the box above.

Trailing commas. {"key":"value",} is invalid. The grammar is object = begin-object [ member *( value-separator member ) ] end-object, so a separator must be followed by a member. Modern JavaScript and Python both allow the trailing comma, which is why it is such a common paste failure. The error points at the comma itself.

Single quotes and unquoted names. A name is a string, and a string is delimited by quotation marks (U+0022) only. {'key':'value'} and {key:"value"} are JavaScript object literals, not JSON. Curly quotes pasted from a word processor fail the same way, and the error says so.

Comments. There is no comment production at all. JSON5 and JSONC add one (VS Code's settings files are JSONC), but neither is JSON, and a strict parser will reject them.

NaN, Infinity and undefined. None has a JSON spelling, and none will parse. Python's True, False and None fail too: the JSON literals are lowercase true, false and null.

Raw control characters inside strings. A tab or line break typed inside the quotes is an error, because RFC 8259 §7 says it must be escaped; the error suggests the escape to write. Whitespace between tokens is only space, tab, line feed and carriage return (§2), so a no-break space copied from a web page is an error too, reported where it sits.

Unpaired surrogates are the exception: they are legal, and they are a known hazard. RFC 8259 §8.2 notes that the ABNF permits bit sequences that cannot encode Unicode characters; for example, "\uDEAD" (a single unpaired UTF-16 surrogate), typically produced when a library truncates a UTF-16 string without checking whether the truncation split a surrogate pair. This page accepts it, keeps the escape as written and adds a note, so the defect stays visible.

Two leniencies, both allowed by the RFC and both stated: a byte order mark at the very start is ignored and noted (§8.1 says a parser MAY ignore the presence of a byte order mark rather than treating it as an error), and nesting deeper than 1,000 levels is refused (§9 lets an implementation set limits on the maximum depth of nesting).

Where a valid JSON document can still be a lossy one

01

JSON has two current standards that were written to agree: ECMA-404 (1st edition 2013, 2nd edition 2017) defines the syntax, and RFC 8259 (December 2017, Internet Standard STD 90) adds interoperability guidance on top of the same grammar.

02

Duplicate names are legal but undefined. RFC 8259 §4: names SHOULD be unique, and where they are not, the behavior of software that receives such an object is unpredictable. JSON.parse keeps the last pair silently; this page keeps both and notes the second.

03

The interoperable integer range is smaller than the grammar's. RFC 8259 §6 says only integers in [-(2**53)+1, (2**53)-1] are values implementations will agree exactly on. 9007199254740993 is valid JSON that a binary64 reader holds as 9007199254740992.

04

The RFC names a specific literal as a warning sign: 1E400 may indicate potential interoperability problems. In JavaScript it parses to Infinity, which has no JSON spelling, so JSON.stringify writes null.

05

Integer-like names get reordered by JavaScript. Through JSON.parse, {"10":"a","9":"b"} comes back as {"9":"b","10":"a"}: ECMAScript orders array-index-shaped keys numerically before the rest. RFC 8259 §4 notes libraries differ on whether member order is even visible, so this is conforming, and still a surprise in a diff.

06

Name comparison has to resolve escapes first. §8.3 warns that a comparator working on raw text may incorrectly find that "a\\b" and "a\b" are not equal. The duplicate check here compares names after resolving escapes, so "a" and "a" are reported as the same name.

Frequently Asked Questions

  • No. This page changes whitespace only: strings and numbers are copied character for character, member order is kept, and duplicate names are kept. Strip the whitespace from the output and from your input and you get the same text. Where your JSON contains something a JSON.parse-based reader would handle differently (a repeated name, an integer wider than 2⁵³−1, a number binary64 cannot hold, an unpaired surrogate), a note under the output says what and where, and the output still keeps it as you wrote it.
  • All three run the same strict parse. Format then writes one member or element per line at your chosen indent, with a space after each colon; Minify writes the same tokens with no whitespace at all; Validate Only stops after the parse and reports the verdict and any notes without producing text. Because only whitespace differs, minifying the formatted output gives exactly the minified output.
  • JSON does not allow a comma after the last element of an array or the last member of an object: in RFC 8259's grammar a comma must be followed by another value. {"name": "Alice",} is invalid; remove the comma after "Alice". JavaScript and Python both accept the trailing comma, which is why it is such a common paste failure. The error gives the line and column of the comma itself, and Show in input selects it.
  • No. RFC 8259's grammar has no comment production at all, so there is nowhere in a JSON text where // or /* */ is legal, and this page rejects a document containing either. If you need annotated configuration, JSON5 and JSONC (JSON with Comments — the dialect VS Code uses for its own settings files) both add them, and both are separate formats rather than relaxed JSON: a parser that accepts them is by definition not enforcing RFC 8259. The usual workaround inside strict JSON is a dedicated member — a "_comment" name your consumer ignores.
  • RFC 8259 §1 counts four primitive types, strings, numbers, booleans (true/false) and null, and two structured types, objects (unordered name/value pairs in braces) and arrays (ordered values in brackets). There is no date, binary or integer type: a date is a string by convention, and a number is just a decimal literal whose precision the receiving software decides.
  • Because the grammar allows a number a JavaScript value cannot hold. RFC 8259 §6 puts no limit on magnitude or precision in the syntax, but says that integers in the range [-(2**53)+1, (2**53)-1] are interoperable in the sense that implementations will agree exactly on their numeric values, which is exactly the set of integers an IEEE 754 binary64 value holds without loss. A tool that formats through JSON.parse rounds anything wider, so the 64-bit ID 12345678901234567890 comes back as 12345678901234567000: valid JSON, wrong ID, no error. This page keeps the digits you wrote and adds a note with the value a binary64 reader would see. The fix in your own system is the same either way: send 64-bit identifiers as strings, the only representation both ends will agree on.
  • No. Parsing, formatting, validating and minifying all run in the page, the input is not written to the address bar or to browser storage, and the Download button assembles the file locally with the Blob API. You can confirm it in your browser's network panel: the page's usual beacons appear there, but none of them carries your JSON. There is no account and no size limit beyond what your browser will hold in a text box.

Related News

You may be interested in these recent stories from our newsroom.

View all news →

Method & sources

How it computes

A strict RFC 8259 parser in the page re-lays out the tokens as written: strings, numbers, member order and duplicate names are kept, so only whitespace changes. Errors give the exact line and column. Notes flag duplicate names (compared after escapes, §8.3), integers outside ±(2^53−1) (§6), numbers binary64 cannot hold, unpaired surrogates (§8.2) and an ignored leading BOM (§8.1).

What this tool implements

  • Grammar: exactly RFC 8259 / ECMA-404. No comments, trailing commas, single quotes, unquoted names, NaN, Infinity or undefined, no unescaped control characters in strings (§7), and only space, tab, LF and CR as whitespace (§2). Acceptance is fuzz-tested against V8's JSON.parse on 6,000 generated and mutated texts: the two must accept exactly the same set.
  • Lossless layout: the output is the input's tokens with new whitespace. Minifying the formatted output reproduces the minified input character for character; this is pinned in the test suite. A JSON.parse + JSON.stringify round trip, which the page used until 2026-11-05, changes duplicates, large integers, member order and spellings.
  • Duplicate names (RFC 8259 §4, "SHOULD be unique"): all pairs are kept and each repeat is reported with its position and the first occurrence's. ECMA-262 JSON.parse note 2: "lexically preceding values for the same key shall be overwritten", which is what a JSON.parse-based reader will do.
  • Numbers (RFC 8259 §6): an integer literal outside [-(2**53)+1, (2**53)-1] is reported; any literal whose decimal value differs from the binary64 value JSON.parse produces is reported with that value (12345678901234567890 → 12345678901234567000, 1E400 → Infinity, written null by JSON.stringify).
  • Errors carry the 1-based line and column (UTF-16 code units) of the first character that breaks the grammar; a trailing-comma error points at the comma, an unclosed container names where it opened. The page can select that character in the input.
  • Stated leniencies, both permitted by RFC 8259: a leading byte order mark is ignored and noted (§8.1 "MAY ignore"); nesting deeper than 1,000 levels is refused (§9 "may set limits on the maximum depth of nesting").
Show 1 more
  • Not implemented and named as such: JSON5, JSONC, comment preservation, JSON Lines, streaming, key sorting and schema validation. Nothing is transmitted.

Sources

  • RFC 8259 (STD 90), The JavaScript Object Notation (JSON) Data Interchange Format, IETF, December 2017 — §2 grammar and whitespace, §4 objects and duplicate names, §6 numbers and the interoperable range, §7 strings, §8.1 byte order mark, §8.2 unpaired surrogates, §8.3 string comparison, §9 parser limits, §13 examples (used as test fixtures): https://www.rfc-editor.org/rfc/rfc8259
  • ECMA-404, The JSON Data Interchange Syntax, 2nd edition, December 2017 (1st edition October 2013): https://ecma-international.org/publications-and-standards/standar…
  • ECMA-262, ECMAScript Language Specification — §25.5.2 JSON.parse (note 2 on duplicate names), §25.5.4 JSON.stringify, §10.1.11.1 OrdinaryOwnPropertyKeys (array-index keys first, in ascending numeric order): https://tc39.es/ecma262/

What can make this go out of date

  • None at runtime. The page makes no network request while you format, validate, minify or download, and the input is not stored or put in the URL.
Advertisement
Pre-footer · AD-W3 728 × 90