Developer Tools

JSON Formatter & Validator

Format, validate, beautify and minify JSON instantly in your browser. 100% private: your data never leaves your device. No signup, and nothing you paste is uploaded.

Last updated

Instant Formatting
Syntax Validation
Minify & Compact
100% Private
Our networkdiscount5Fresh deals. Five at a time.Price drops and coupon codes, ending soonest first.See today’s deals
{ }
JSON Formatter & Validator
Input JSON empty
Formatted Output ready
Ready. Paste JSON on the left to format.

How the JSON Formatter Works

Valid JSON needs double quotes around every key and string, no trailing commas and no comments; anything else fails to parse. Paste your JSON above to pretty print it with 2 spaces, 4 spaces or tabs, minify it or sort its keys. If it is invalid, the formatter shows the line and column of the first error and what it expected there. It all runs in your browser.

The input is parsed with the browser's built in strict JSON parser, then printed again with the indentation you pick. Nothing is sent to a server, so the tool also works offline once the page has loaded. Formatting never changes the data itself, with one exception covered below: numbers too large or too precise for JavaScript.

Common JSON Errors and How to Fix Them

These are the messages the formatter shows for the mistakes people make most often. Line and column point to the character where parsing stopped, which is usually just after the real mistake.

InputMessage shownFix
{"a": 1,}Trailing comma before }Delete the last comma
{'a': 1}Property names need double quotes, not single quotesUse "a"
{a: 1}Expected a property name in double quotesQuote the key
{"a": 1 "b": 2}Expected ',' or '}' after a property value (missing comma?)Add a comma after 1
{"a": NaN}Unexpected word "NaN"Use null or a number
{"a": 007}Numbers cannot have leading zerosWrite 7, or "007" as a string
// note before the dataComments are not allowed in JSONRemove the comment
{"dir": "C:\data"}Invalid escape sequence in a stringDouble the backslash: C:\\data

If the error is on the last line, look for a missing closing } or ]. JSON copied from a JavaScript file often has single quotes, comments or trailing commas, all of which are legal in JavaScript and JSON5 but not in JSON.

Big Numbers Lose Precision

JSON itself allows numbers of any length, but JavaScript stores every number as a 64-bit double. Whole numbers are exact only up to 9,007,199,254,740,991 (253 − 1). Past that, digits change silently when the JSON is parsed and printed again.

In your JSONAfter formattingChanged?
90071992547409919007199254740991No
90071992547409939007199254740992Yes
1234567890123456789012345678901234567000Yes
0.12345678901234567890.12345678901234568Yes
1e400nullYes (too large)
1.501.5No, same value

The formatter checks every number and warns in the status bar when one would change. The fix is on the producing side: send long IDs, account numbers and exact decimals as strings, such as "id": "12345678901234567890".

Minified vs Indented File Size

The Sample button's JSON (one user record with 20 keys, nested 3 levels deep) in each output style:

StyleSizevs minified
Minified349 bytesbaseline
Tab indent461 bytes+32%
2 spaces525 bytes+50%
4 spaces653 bytes+87%

Deeply nested data gains more from minifying, flat arrays of short values less. Gzip, which most web servers apply, removes most of the difference in transfer, so minify for storage and logs and indent for anything a person will read.

JSON Value Types Quick Reference

TypeExampleRules
String"New York"Double quotes only; escape " and \; no raw line breaks
Number-12.5e3No leading zeros, no +, no NaN or Infinity, no hex
BooleantrueLowercase true or false
NullnullLowercase; there is no undefined
Array[1, "a", null]Items separated by commas, no trailing comma
Object{"key": "value"}Keys must be strings; duplicate keys are allowed by the grammar but the last one wins here

Need the data in a spreadsheet? The JSON to CSV converter flattens nested objects into columns, and the diff checker compares two formatted JSON files line by line.

Method and sources. JSON grammar from RFC 8259 and ECMA-404; parsing and printing use the ECMAScript JSON.parse and JSON.stringify functions built into your browser. Numbers are IEEE 754 double precision values, so integers are exact up to 253 − 1 (Number.MAX_SAFE_INTEGER). The precision table and the size table were produced by running the same code as the tool in Node.js.

Scheduling a job that produces this JSON? The cron expression builder writes and explains the schedule line.

JSON Formatter Guide

JSON (JavaScript Object Notation) is a lightweight data format used to exchange data between applications and APIs. Minified JSON has all whitespace removed for network efficiency, making it unreadable. Formatted JSON adds indentation and line breaks to make it human-readable without changing its meaning. APIs commonly return minified JSON; this tool beautifies it instantly so you can read and debug it.

Yes, completely. All formatting happens in your browser using JavaScript's built-in JSON.parse() and JSON.stringify(). No data is sent to any server. This tool works entirely offline once the page loads: you can disconnect from the internet and it will continue to work. We have no access to or logs of what you paste. Suitable for sensitive API keys, tokens, or internal JSON data.

The most common errors: Trailing commas after the last item in an object or array (not allowed in JSON, but allowed in JavaScript). Single quotes instead of double quotes for strings and keys. Unquoted keys, all keys must be in double quotes. Comments, JSON does not support // single-line or /* block */ comments. Undefined or NaN values: only strings, numbers, booleans, null, arrays, and objects are valid. The validator in this tool shows the line and column of the first error and what it expected there.

JSON is a strict text format: all keys must be in "double quotes", and values can only be strings, numbers, booleans, null, arrays, or objects. JavaScript objects are more flexible: they allow unquoted keys, single quotes, trailing commas, functions as values, and comments. JSON is a strict data-interchange subset of JavaScript object syntax. This is why JSON.parse('{"key": undefined}') throws an error,undefined is a JavaScript concept, not a JSON value.

In JavaScript: wrap JSON.parse(str) in a try-catch block. If it throws, the JSON is invalid; the error message will indicate the position. In Python: use json.loads(str) inside a try-except json.JSONDecodeError block. In Java: use ObjectMapper.readTree(str) from Jackson, wrapped in a try-catch. In Go: json.Valid([]byte(str)) returns a boolean. In Bash: echo "$json" | python3 -m json.tool validates and pretty-prints in one command.

Minifying JSON removes all non-essential whitespace (spaces, tabs, newlines) to produce the most compact valid JSON string. Use minification when sending JSON over a network (API responses, webhooks) to reduce payload size and improve performance. The sample on this page is 349 bytes minified and 525 bytes with 2-space indentation, so minifying saves about a third. In development, use formatted JSON for readability. In production API responses, minify automatically: frameworks like Express.js and FastAPI do this by default. Use the Minify button above to compact your JSON for network use.

This tool processes JSON entirely in your browser's JavaScript engine. In practice, it handles up to several megabytes of JSON without issues on modern browsers. Very large JSON files (10MB+) may cause a brief pause during formatting but will complete successfully. For JSON files over 50MB, consider using a command-line tool: python3 -m json.tool large.json or jq . large.json for faster processing. The browser textarea may scroll slowly with very large outputs, but the formatting itself is not size-limited.

JSON5 is a superset of JSON that adds JavaScript-like features: unquoted keys, single quotes, trailing commas, comments, and multi-line strings. It was created to make configuration files more human-friendly. JSON5 files use the .json5 extension. This formatter uses the standard JSON.parse() which does not support JSON5 syntax. If you have JSON5 input with trailing commas or comments, remove them first. Babel, for example, reads .babelrc files as JSON5. True JSON validation uses strict JSON syntax only.

Use the Sort Keys button above. Sorting keys alphabetically makes it easier to scan large JSON objects, compare two JSON responses side-by-side, or produce deterministic output for testing. The sort is applied recursively: all nested objects are also sorted. Note that JSON technically does not guarantee key order (objects are unordered), but in practice most parsers preserve insertion order. Sorted JSON is functionally identical to unsorted JSON: any valid parser will produce the same data regardless of key order.

All three produce valid, functionally identical JSON: the difference is visual style. 2-space indentation is the most compact and common in web APIs and JavaScript projects (the default in Node.js JSON.stringify when using null, 2). 4-space indentation is the Python convention (used by json.dumps(indent=4)) and produces more spacious, readable output. Tab indentation is preferred by some editors (Vim, older conventions) and allows users to configure tab width visually. Select the style that matches your project's code style guide. This formatter defaults to 2 spaces.

JavaScript parses every JSON number as a 64-bit double, which is exact for whole numbers only up to 9,007,199,254,740,991. A value such as 12345678901234567890 comes back as 12345678901234567000. The formatter warns you when this happens. Keep long IDs and exact decimals as strings in JSON to avoid it.

The grammar does not forbid them, but RFC 8259 says names within an object should be unique because parsers disagree on what to do. JavaScript, and therefore this formatter, keeps the last value: {"a": 1, "a": 2} becomes {"a": 2}. Other parsers may keep the first value or reject the document, so remove duplicates at the source.