JSON Formatter & Validator

By Asira Tools Team · Last updated 20 November 2026

Paste JSON to format it, validate it, or minify it. Errors are explained in plain language, and nothing leaves your browser.

Advertisement

JSON Formatter & Validator

Valid JSON
Formatted output4 keys at the top level

Your JSON is processed entirely in your browser — it is never sent to a server.

How it works:

The tool parses your text with the JSON grammar (JSON.parse), then re-prints it with the indentation you choose — or with no whitespace at all when you minify. If parsing fails, it reports the error instead of guessing.

What Does a JSON Formatter Do?

A JSON formatter takes JSON text — the data format used by almost every web API, config file, and data feed — and re-prints it so a human can read it. Minified JSON arrives as a single dense line with no spaces; formatted JSON spreads the same data over many lines with indentation, so the structure is visible at a glance. The same tool also validates: if the JSON has a syntax error, it says so and points at the problem instead of silently producing wrong output.

JSON stands for JavaScript Object Notation, and it is the standard way for systems to exchange structured data. A weather API returns JSON; a settings file is often JSON; a front-end app sends JSON to its server. Developers meet JSON daily, and most of the time it arrives minified — machines do not need whitespace, so APIs strip it out to save bandwidth. Formatting it back is the first step in understanding what the data actually says.

How to Use This Formatter

Paste your JSON into the input box. The formatted output appears immediately, and the status line tells you whether the JSON is valid and how many keys or items sit at the top level. Choose 2-space or 4-space indentation to match your project's style, or choose Minify to compress formatted JSON back into a single line for sending over the network or pasting into a compact config value.

Everything happens in your browser: the JSON you paste is never uploaded to a server. That matters because JSON often contains API keys, personal data, or internal identifiers that should not be pasted into a tool that phones home. You can verify this by formatting with your network disconnected — the tool keeps working, because the work is local.

What Valid JSON Looks Like

JSON has a small, strict grammar. The whole document is one value: an object (curly braces with key-value pairs), an array (square brackets with values), a string, a number, true, false, or null. Objects use double-quoted keys and a colon between each key and its value; pairs are separated by commas. Arrays hold values separated by commas. Strings use double quotes, never single quotes. Numbers are plain decimal notation — no commas, no currency symbols, no trailing decimal points.

Here is the same data minified and formatted. Minified, it is one line:

{"name": "Ada Lovelace", "born": 1815, "knownFor": ["first programmer", "Analytical Engine"], "active": true}

Formatted with 2-space indentation, the structure is obvious: the object has four keys, and the "knownFor" key holds an array of two strings. Both versions carry exactly the same data — formatting changes only the whitespace, never the meaning. That is why a formatter is safe to run on any JSON: the output parses to the identical data structure as the input.

Common JSON Errors and How to Fix Them

Trailing commas. A comma after the last item in an object or array — {"a": 1,} — is the most common JSON error. It is allowed in JavaScript and in some config formats, but it is not valid JSON. Remove the trailing comma.

Single quotes. JSON strings must use double quotes. {'a': 1} is not valid JSON, even though it works in JavaScript. Replace the single quotes with double quotes.

Unquoted keys. Every key in a JSON object must be a double-quoted string: {"a": 1}, not {a: 1}. This is another case where JavaScript is more lenient than JSON.

Comments. JSON has no comments. A // note or /* note */ inside JSON is a syntax error. If you need notes, put them in a separate field such as "_comment": "note here", or use a format that supports comments, like JSON5 or YAML.

Undefined, NaN, and Infinity. These JavaScript values are not valid JSON. Use null for a missing value, and a quoted string or null for a number that has no finite value.

When the formatter reports an error, it includes the parser's message, which usually names the position where parsing failed. The mistake is often just before that position — a missing comma on the previous line, or a quote that was never closed.

Formatting vs Minifying: When to Use Each

Format JSON when a human needs to read it: debugging an API response, reviewing a config file, writing documentation, or checking data by eye before importing it. Indentation makes nesting visible, so a misplaced brace or a value at the wrong depth stands out immediately. Two spaces is the most common indentation in the JavaScript world; four spaces is common in Python and Java projects. Either is fine as long as a project picks one and sticks to it.

Minify JSON when a machine will read it and size matters: sending a payload over a network, storing JSON in a database column, or embedding JSON in a URL or a single-line config value. Minifying removes all unnecessary whitespace, which typically shrinks a formatted document by 20 to 30 percent — a 10 KB formatted file often minifies to about 7 or 8 KB. The savings grow with the document, which is why APIs minify by default.

Tips for Working with JSON

Validate before you send. A single trailing comma can make an entire API request fail with a cryptic error. Pasting the payload into this formatter before sending it catches the mistake in seconds and shows exactly where the parser stopped.

Keep keys consistent. JSON keys are case-sensitive: "Name" and "name" are different keys. Pick one naming style — camelCase or snake_case — and use it for every key in a document, so consumers of the data do not have to guess.

Prefer arrays of objects for lists. A list of records reads naturally as an array of objects with the same keys, like [{"name": "Ada", "age": 36}, {"name": "Grace", "age": 85}]. That shape converts cleanly to a table — see the CSV to JSON converter for moving between tables and JSON.

Watch out for large numbers. JSON numbers are parsed as double-precision floating point in most languages, which cannot represent integers above 2^53 (9,007,199,254,740,992) exactly. IDs larger than that should be strings, not numbers.

Common Mistakes to Avoid

The most common mistake is assuming JSON is the same as a JavaScript object literal. It looks similar, but JSON is stricter: double quotes only, no trailing commas, no comments, no functions, no undefined. Code that builds JSON by concatenating strings usually produces one of these errors eventually; building the data as an object and serializing it with a proper JSON library avoids the whole class of mistakes.

Another frequent error is copying JSON out of an error message or a log, where quotes may have been escaped or line breaks removed. If pasted JSON fails to validate, check whether the source escaped the quotes (backslash-quote sequences) or wrapped the JSON in extra quotes — both are common when JSON travels through logs, chat apps, or spreadsheets.

Finally, remember that formatting never changes the data. If a formatted document behaves differently from the minified original, the difference is somewhere else — a changed value, a different key, or a different document entirely. For text statistics on any pasted content, see the word counter; for encoding text safely, the Base64 encoder.

Advertisement

Frequently Asked Questions

What is the difference between formatting and minifying JSON?

Formatting adds indentation and line breaks so humans can read the structure; minifying removes all unnecessary whitespace so the file is smaller for machines. Both contain exactly the same data — only the whitespace changes.

Why is my JSON invalid when it looks fine?

The usual causes are a trailing comma after the last item, single quotes instead of double quotes, an unquoted key, or a comment. JSON is stricter than JavaScript: it allows none of those. The error message names the position where parsing failed — the mistake is usually just before it.

Is my JSON data sent to a server when I use this tool?

No. Formatting and validation run entirely in your browser using JavaScript. Your JSON never leaves your device, so it is safe to format data that contains API keys or personal information.

Can JSON contain comments?

No. The JSON specification has no comments, and a // or /* */ comment makes the document invalid. If you need notes, add a field such as "_comment" or use JSON5 or YAML, which do support comments.

What is the maximum size of JSON I can format here?

There is no fixed limit in this tool — it runs in your browser, so the practical limit is your device's memory. Documents up to several megabytes format instantly; very large files (tens of megabytes) may take a few seconds.