BrowserTools
Advertisement
Home / Validators / JSON Validator & Formatter

JSON Validator & Formatter

Validate, format and minify JSON in your browser with detailed error locations.

Loading JSON Validator & Formatter… If nothing happens, please enable JavaScript.

Frequently asked questions

Is my JSON sent to a server?
No. Parsing and formatting happen entirely in your browser using the native JSON.parse and JSON.stringify functions built into the JavaScript engine. Your data never leaves your device, making this tool safe to use with API responses, database exports, or any confidential JSON payloads.
What are the exact rules that make JSON valid?
JSON has a strict grammar defined by RFC 8259 and ECMA-404. Keys must be double-quoted strings. String values must use double quotes, not single quotes. Trailing commas after the last element in an object or array are forbidden. Comments are not allowed. Numbers cannot have leading zeros or a trailing decimal point. The document must contain exactly one top-level value (an object, array, string, number, boolean, or null).
What is the difference between pretty-printing and minifying JSON?
Pretty-printing (also called formatting or beautifying) adds newlines and indentation to make the structure visually clear and easy for humans to read. Minifying removes all unnecessary whitespace — spaces, tabs, and newlines — to produce the most compact valid JSON string. Minified JSON is used in production API responses and configuration files where every byte of bandwidth or storage matters; pretty-printed JSON is used in source control, documentation, and debugging.
How is JSON different from JavaScript object literal syntax?
JSON is a strict subset of JavaScript value syntax, but the two are not identical. JSON requires double-quoted keys and string values; JavaScript object literals allow unquoted or single-quoted keys. JSON forbids trailing commas, comments, undefined values, functions, and symbol keys — all of which are valid in JavaScript. JSON.parse is intentionally strict about these rules so that JSON can be parsed safely by non-JavaScript systems.
What size of JSON can I validate and format?
The tool accepts JSON of any size, but practical limits exist. Payloads up to several megabytes parse and format in milliseconds. Very large documents (tens of megabytes or more) may cause noticeable delays or memory pressure in the browser tab. For processing extremely large JSON files — server logs, data exports — command-line tools like jq are more appropriate.
Does the validator support JSON5 or JSONC (JSON with comments)?
No. This tool uses the strict JSON grammar defined by RFC 8259, which forbids comments and trailing commas. JSON5 and JSONC are unofficial extensions that allow these features. Many configuration file formats (TypeScript's tsconfig.json, VS Code settings) use JSONC but are parsed by specialised parsers that are more permissive than standard JSON.parse. If your input uses these extensions, you need a JSONC or JSON5 parser.
Can I use this to format JSON inside a string (escaped JSON)?
If you have a JSON string that has been embedded inside another JSON string — with its inner quotes escaped as \" — you will first need to decode the outer JSON to extract the inner string, then parse and format it separately. A common scenario is API error messages that include a raw JSON payload as a string value. You can paste the entire outer document, copy the escaped string value, and paste it for a second formatting pass.
Is JSON the same as BSON or MessagePack?
No. JSON is a text format; BSON (Binary JSON) and MessagePack are binary serialisation formats that encode the same logical data types as JSON but in a compact binary representation rather than UTF-8 text. BSON is used internally by MongoDB and supports additional types like dates and binary data. MessagePack is used for high-performance inter-service communication. A JSON tool cannot parse BSON or MessagePack directly.
Why does the error message only show the first error?
JSON.parse stops at the first syntax error it encounters, because subsequent tokens may be unparseable in context — fixing the first error could make the rest of the document valid or reveal entirely different errors. This is the same behaviour as most JSON parsers. Fix the reported error and re-validate; if more errors exist, they will appear one at a time.
What is a common mistake that makes JSON invalid?
The most frequent mistake is a trailing comma after the last property in an object or the last element in an array — for example, {"a": 1,} or [1, 2, 3,]. This is valid in JavaScript and many configuration formats but explicitly forbidden in JSON. Other common errors include using single quotes for strings, adding a // comment, and forgetting to quote property names. The error message from JSON.parse will point to the exact character position where parsing failed.

About JSON Validator & Formatter

JSON (JavaScript Object Notation) is a lightweight, human-readable data interchange format based on a subset of JavaScript syntax. It was popularised by Douglas Crockford in the early 2000s as a simpler alternative to XML for exchanging data between web clients and servers. Standardised as RFC 4627 in 2006 and later ECMA-404 and RFC 8259, JSON has become the universal language of web APIs, configuration files, and data storage. Its six value types — string, number, boolean, null, array, and object — map cleanly onto the data structures of virtually every programming language.

JSON is unavoidable in modern development. REST APIs return JSON responses. Configuration files for tools like ESLint, TypeScript, and npm use JSON. NoSQL databases like MongoDB store documents as BSON (binary JSON). Serverless function event payloads are JSON objects. Developers routinely need to inspect, format, or validate JSON from API responses, database exports, log files, webhook payloads, and configuration templates. A single misplaced comma or unmatched bracket makes the entire document invalid, and raw minified JSON from a production API is nearly impossible to read without formatting.

This JSON validator and formatter parses your input locally in the browser using the native JSON.parse function — the same parser used by every JavaScript runtime. It highlights the exact line and column of any syntax error so you can find and fix problems immediately. Once valid, the tool pretty-prints the JSON with configurable indentation for readability, or minifies it by stripping all unnecessary whitespace to reduce payload size. Because everything runs in your browser, your JSON data — which may contain API keys, user records, or confidential business data — is never sent to any server.

Common JSON mistakes include trailing commas after the last item in an array or object (valid in JavaScript but forbidden in JSON), single-quoted strings (JSON requires double quotes), and comments (JSON has no comment syntax, unlike JSONC or JSON5). Numbers with leading zeros (like 007) are also invalid. If you are working with a format that extends JSON with these features, a JSONC or JSON5 parser is needed instead — standard JSON.parse will reject them.

How JSON conquered the web

JSON was created and popularised by Douglas Crockford, who registered the domain json.org in 2001 and began advocating for JSON as a lightweight alternative to XML for AJAX data exchange. Crockford's key insight was that JavaScript's object and array literal syntax was already a valid data format — it just needed to be documented, restricted to safe types, and promoted. He famously claimed he 'discovered' rather than invented JSON, noting that the syntax was already latent in JavaScript itself.

Despite its simplicity, JSON's path to standardisation was surprisingly contentious. Crockford initially published it under a licence that included the phrase 'The Software shall be used for Good, not Evil', which caused it to be classified as non-free by some open-source organisations. When ECMA formalised JSON as ECMA-404 in 2013 and the IETF published RFC 8259 in 2017, they used a clean licence — but Crockford kept the 'Good, not Evil' clause in the original json.org specification, creating a persistent (and somewhat humorous) licensing footnote in web standards history.

Today, JSON is arguably the most widely parsed data format in existence. Every major programming language ships a JSON parser in its standard library. REST APIs, GraphQL responses, NoSQL databases, configuration files, log aggregation systems, and serverless event buses all use JSON as their native format. The irony is that JSON, which was designed to be simpler than XML, has itself become so ubiquitous that entire ecosystems of JSON-adjacent formats — JSON5, JSONC, NDJSON, JSON Schema, JSON Pointer, JSON Patch — have grown up around it to address its limitations.

Advertisement