JSON Formatter & Validator

Paste JSON to check it's valid, then beautify or minify it in one click.

No input yet

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based format for structuring data, built from key-value pairs, arrays, and nested objects. It's the standard format most web APIs use to send and receive data, and it's readable enough for humans to inspect directly, especially once it's properly indented. Despite the name referencing JavaScript specifically, JSON is entirely language-independent, every major programming language, Python, Java, Ruby, Go, PHP, and dozens more, has built-in or widely available libraries for reading and writing it, which is exactly why it became the default data format for communication between systems written in completely different languages.

Beautify vs Minify

Beautify adds consistent indentation and line breaks, making nested structures easy to read and debug. Minify strips out all unnecessary whitespace, producing the smallest possible output, useful when you're sending JSON over a network and want to save bytes, since whitespace has no effect on how the data is parsed. As a rule of thumb, beautified JSON belongs in places a human will read it, a config file in a repository, documentation, a debugging session, while minified JSON belongs in places only a machine will read it, an actual API request or response body in production, where every saved byte reduces bandwidth and parsing time at scale.

Common JSON Errors

A Worked Example: Beautify and Minify

The default example loaded into this tool, {"name":"Calc369","tools":35,"categories":[...],"free":true}, demonstrates both directions clearly. Clicking Beautify expands it into readable, 2-space-indented output with each key, value, and array item on its own line, exactly what JavaScript's JSON.stringify(data, null, 2) produces. Clicking Minify collapses it back down to the single-line compact form with every unnecessary space removed, exactly what JSON.stringify(data) produces with no formatting arguments. Both directions parse the same underlying data structure and just re-serialize it differently, which is why repeatedly switching between Beautify and Minify never changes the actual data, only its whitespace and layout.

How This Tool Validates Your JSON

Validation here runs through JavaScript's native, built-in JSON.parse() function, the exact same parser every browser and Node.js environment uses internally to parse JSON anywhere else. This matters because it means a "Valid JSON" result here is a genuine guarantee that the same text will parse correctly wherever else it's used in a JavaScript environment, an API client, a Node.js script, a browser's fetch() response handler, rather than a simplified or approximate check specific to this tool. When parsing fails, the error message shown comes directly from that same native parser, so it reflects exactly what error a real application would encounter trying to process the same broken JSON.

What Reformatting Can (and Can't) Change

Beautifying or minifying JSON is meant to be a purely cosmetic operation, whitespace in and whitespace out, with the underlying data unchanged. There are two subtle exceptions worth knowing about, both stemming from how JavaScript represents numbers internally. A number written as 10.50 in your original JSON comes back as 10.5 after formatting, since trailing zeros aren't meaningfully different in JavaScript's number type and get dropped during re-serialization. More significantly, a very large integer, larger than 9,007,199,254,740,991 (JavaScript's maximum safely representable integer), can shift by a small amount after formatting, for example 9007199254740993 round-trips as 9007199254740992, because JavaScript stores all numbers as 64-bit floating point values that can't represent every large integer exactly. If your JSON contains IDs or values that large, consider representing them as strings instead of raw numbers to avoid this precision loss entirely.

JSON vs Other Data Formats

JSON's biggest historical competitor was XML, the dominant data interchange format before JSON's rise, XML uses verbose opening and closing tags for every element and requires a separate schema definition for validation, where JSON's structure is largely self-describing and far more compact for the same data. YAML, another common alternative especially in configuration files (Docker Compose, GitHub Actions, Kubernetes), trades JSON's explicit brackets and quotes for indentation-based structure, which some find more readable for hand-written config but which is also more prone to subtle whitespace-related bugs. JSON's specific advantage has always been its direct mapping to JavaScript's native object and array syntax, and its simplicity, a complete grammar for the format fits on a single page, which is a large part of why it became the near-universal default for web APIs despite XML's earlier dominance.

Common Real-World Uses for a JSON Formatter

Debugging API responses. Many APIs return minified JSON to save bandwidth, pasting a raw response here instantly makes its structure readable, which is often the fastest way to understand an unfamiliar API's data shape, especially for a new endpoint you haven't worked with before.

Reviewing configuration files. Tools like package.json, tsconfig.json, and many others use JSON for configuration, validating and reformatting them here catches syntax errors before they cause a confusing build failure.

Inspecting webhook payloads. Services that send webhook notifications typically deliver a JSON payload, formatting it makes the data easy to scan for the specific field you're looking for.

Sanity-checking hand-written JSON before deployment. Manually editing a JSON config file is a common source of small syntax slips, running it through a validator before committing catches an error in seconds rather than after a failed deploy.

Nested Structures: Objects Inside Arrays Inside Objects

Real-world JSON, especially from APIs, is rarely as flat as the simple example loaded into this tool, it's common to see arrays of objects nested several levels deep, an object representing an order might contain an array of line items, where each line item is itself an object containing a nested product object. This is exactly where beautifying earns its keep: deeply nested, minified JSON is nearly impossible to visually parse, since brackets and braces blur together with no indentation to show which closing character belongs to which opening one. Once beautified, the indentation level directly reflects nesting depth, making it far easier to trace which fields belong to which object as you scan down through several levels, a skill that becomes essential once you're regularly debugging real API payloads rather than simple flat objects.

A Brief History of JSON

JSON was popularized in the early 2000s by Douglas Crockford, who didn't so much invent a new format as formally specify and name a pattern that was already implicitly available, JavaScript's own object literal syntax, and promote it as a lightweight, language-independent data interchange format. It was deliberately designed to be a strict subset of JavaScript's own syntax, which is exactly why every valid JSON document is also valid JavaScript, though the reverse isn't true, JavaScript object literals allow things like unquoted keys, trailing commas, and comments that strict JSON forbids. JSON was formally standardized as RFC 8259 by the IETF, cementing the exact grammar (and its deliberate restrictions) that this tool's underlying parser enforces today, decades after informal JSON usage had already become the web's dominant data format.

Frequently Asked Questions

Why does it say my JSON is invalid when it looks fine?

The most common cause is a trailing comma or single quotes instead of double quotes, both are valid in regular JavaScript but not in strict JSON. Check the error message above the input box; it points to roughly where the problem is.

Is my data sent anywhere when I paste it here?

No, formatting and validation both happen locally in your browser using JavaScript's built-in JSON parser. Nothing you paste is uploaded.

Does JSON support comments?

No, the JSON specification has no provision for comments at all, even though comments are common in JavaScript and many config file formats. Pasting JSON with // or /* */ comments into this tool will show as invalid, remove any comments before validating.

Can JSON have a trailing comma after the last item?

No, unlike some JavaScript styles that tolerate a trailing comma in arrays and objects, strict JSON treats a trailing comma as a syntax error. This is one of the most common reasons hand-edited JSON fails validation.

What data types are valid in JSON?

JSON supports exactly six types: string, number, boolean (true/false), null, array, and object. There's no dedicated date type, no undefined value, and no support for special numeric values like NaN or Infinity, dates are typically represented as ISO 8601 strings by convention instead.

Why did my numbers change slightly after formatting?

This tool parses JSON using JavaScript's native number type, which is a 64-bit floating point value. Trailing zeros like 10.50 get simplified to 10.5, and integers larger than about 9 quadrillion (beyond JavaScript's safe integer range) can lose precision, since they don't fit exactly in that format.