JSON Formatter & Validator
Validate, pretty-print or minify JSON.
Validate, pretty-print or minify JSON.
The JSON Formatter & Validator parses your input with the browser’s native JSON parser. Valid data can be pretty-printed with indentation for readability or minified to remove unnecessary whitespace; invalid input returns a parsing error.
JSON's strict syntax rules, such as requiring double quotes around keys and disallowing trailing commas, are easy to violate accidentally when hand-editing configuration files or API payloads, and a single misplaced comma or bracket can break an entire application, so catching that early with a validator saves significant debugging time later.
For related tasks, try Base64 Encoder / Decoder, URL Encoder / Decoder or HTML Minifier.
The compact object {"a":1,"b":2} can be formatted onto multiple lines with indentation, while preserving the same data structure.
The invalid JSON {“name”:“Ali”,} contains a trailing comma after the last property, which is valid in JavaScript object literals but explicitly disallowed by strict JSON syntax, and this tool would flag it as an error rather than silently accepting it.
A formatter can only fix whitespace and indentation; it cannot fix an actual syntax error, so if validation fails, focus on the specific line and character position mentioned in the error message rather than assuming the formatter itself is broken. Common causes include trailing commas after the last item, single quotes instead of double quotes, and unescaped special characters inside string values.
JSON has strict rules. Keys and strings use double quotes, values can be strings, numbers, true, false, null, arrays or objects, and items are separated by commas with no comma after the last item. Comments are not allowed. The validator reports the position of the first error so you can fix it. Formatting adds line breaks and indentation so that nested data is easy to read, and minifying removes them to save space.
Most invalid JSON comes from a few mistakes. Single quotes instead of double quotes, a trailing comma after the last element, an unquoted key, a missing closing bracket and a stray comment are the usual ones. Values like undefined, NaN or a function are not valid JSON. If the error message points to the end of the input, a bracket or quote is probably missing earlier. Fix the first error and validate again, since later messages may disappear.
JSON is based on JavaScript object syntax but is stricter. A JavaScript object can have unquoted keys and trailing commas, and JSON cannot. Numbers larger than 9,007,199,254,740,991 lose precision when read as JavaScript numbers, so APIs often send large identifiers as strings. Dates have no JSON type and are usually written as text in ISO 8601 format, such as 2026-10-07T12:00:00Z.
Developers format JSON to read API responses, configuration files and logs. Sort or search for keys by pretty-printing the data first. When you share JSON in a bug report, remove private details such as tokens, emails and keys. Because this tool processes the text in your browser and does not send it to a server, it is a reasonable choice for quick checks, but still avoid pasting secrets into any tool you do not control.
For large JSON, indent it so that you can see the structure, then collapse sections to find a value. Keep key names consistent, such as using the same style for every key, and be careful with arrays of objects where one item is missing a field. Write dates in ISO 8601 and numbers as numbers, not strings, unless the number is an identifier. For very large files, consider a line-by-line format where each line is one JSON object, which is easier to process. Validate before you send data to an API.
Consider the text {name: 'Ali', "age": 30,}. It has three problems: the key name has no quotes, the value uses single quotes, and there is a trailing comma after the last item. JSON requires double quotes for keys and strings and does not allow the extra comma. The corrected version is {"name": "Ali", "age": 30}. The validator points to the first error, so you fix them one at a time, validating again after each change. Formatting the result with indentation then makes the structure easy to read and to compare with the data you expected.
JSON is built from two structures: objects, which are collections of named values in curly brackets, and arrays, which are ordered lists in square brackets. They can be nested to any depth, so an order might be an object that contains a customer object and an array of item objects, each with a name, a quantity and a price. To find a value, follow the path through the keys and positions. The order of keys inside an object has no meaning, but the order of items in an array does, so do not rely on keys being in a certain sequence.
JSON is compact and easy for programs to read, which is why most web APIs use it. XML is more verbose but supports attributes and namespaces. CSV is simple for tables but cannot nest data. YAML is friendlier for people to edit and allows comments, but its indentation rules are easy to get wrong. JSON has no comment syntax, no date type and no distinction between integers and decimals, so these conventions come from the application. Choose the format that fits your use, and document how dates, missing values and special numbers are represented.
When a program fails to parse JSON, the message often says something like unexpected token less-than at position 0. This usually means the server returned an HTML page, such as an error or login page, instead of JSON, since HTML begins with a less-than sign. Check the status code and the content type header, then look at the raw response. Other causes include a byte order mark at the start of the file, truncated responses and numbers too large for the language to store exactly. Paste the response into the validator to find the exact point of failure, and remove private data before you share it.
JSON stands for JavaScript Object Notation, a text format for structured data. An object is a set of key and value pairs in curly brackets, and an array is an ordered list in square brackets. A string is text in double quotes. Valid values are strings, numbers, true, false, null, objects and arrays. Parsing reads the text into a data structure, and serialising writes a structure as text. Pretty-printing adds indentation. A schema describes the expected structure.
Use double quotes for keys and strings, put commas between items but not after the last, and match every opening bracket with a closing one. JSON has no comments, no undefined and no trailing commas. Numbers beyond 9,007,199,254,740,991 lose precision in JavaScript, so send large identifiers as strings. If an error points to position 0, the response may be HTML. Validate before sending data to an API, and remove private information before sharing a sample.
No. It parses and serializes the same data structure, although insignificant whitespace changes.
Standard JSON does not allow trailing commas, so they produce an error.
The formatter runs in the browser without an external API.
JavaScript object literal syntax is more permissive than strict JSON; for example, it allows trailing commas and unquoted keys, while this validator enforces the stricter official JSON specification used by APIs and data files.
No, this tool checks only that the JSON syntax itself is valid, not whether it matches a particular expected structure or schema.