How the JSON Formatter Works
Paste any JSON string into the input area and click Format. Choose between 2 spaces, 4 spaces, or tab indentation. The tool validates your JSON first — if it contains syntax errors, you'll see the exact error message with the position. Pretty handy when you're staring at a wall of red and don't know where to look.
Click Minify to strip all whitespace for compact storage or transmission. The stats panel shows the total number of keys, maximum nesting depth, and output size in bytes.
What Is JSON and Why Does It Matter?
JSON (JavaScript Object Notation) is the universal data interchange format for web APIs. Created by Douglas Crockford in the early 2000s, it replaced XML as the dominant format because of its simplicity and readability. Its syntax is based on a subset of JavaScript, making it immediately familiar to web developers — but it's fully language-agnostic. Every major programming language can parse and generate JSON natively or through a standard library. The format represents data as key-value pairs (objects) and ordered lists (arrays), which map naturally to the data structures used in virtually every application.
Every modern API — from weather services to social media platforms, payment gateways to mapping services — sends and receives JSON. Honestly, if you fetch data from a REST API, configure a webhook, write a CI/CD pipeline, or inspect a browser network request, JSON is almost certainly what you're looking at. Understanding its structure matters a lot for web developers, data analysts, QA engineers, and anyone working with APIs or automation scripts. A formatter is the first tool you reach for to make raw, minified API responses readable.
Common JSON Errors and How to Fix Them
- Trailing commas — JSON does not allow a comma after the last element in an object or array, unlike JavaScript.
{"a": 1, "b": 2,}is invalid JSON even though it is valid JS. This is one of the most frequent errors when hand-editing JSON copied from JavaScript source code. Remove the trailing comma and the validator will pass. - Single quotes — JSON requires double quotes for all strings and all key names.
{'name': 'Alice'}is invalid; it must be{"name": "Alice"}. This trips up developers who work primarily in Python or JavaScript, where single quotes are perfectly valid. A find-and-replace from single to double quotes usually fixes the issue, though watch out for apostrophes inside string values. - Missing quotes on keys — In JavaScript, object keys can be unquoted (
{name: "Alice"}), but in JSON every key must be a quoted string ({"name": "Alice"}). This is particularly common when converting JavaScript object literals to JSON for storage or transmission. Always wrap key names in double quotes. - Unescaped special characters in strings — Certain characters inside JSON string values must be escaped with a backslash: double quote (
\"), backslash (\\), newline (\n), tab (\t). If you paste text that contains literal newlines or unescaped quotes inside a string value, JSON parsers will reject it. The formatter will show you the exact position of the problem character. - Comments — JSON does not support comments. Neither
// line commentsnor/* block comments */are valid. If you need comments in a config file, use JSONC (JSON with Comments, supported by VS Code and many tools), or strip comments before parsing. This catches many developers by surprise when copying configuration examples that include explanatory comments.
For the person hunting a misplaced comma in 800 lines of API response
Syntax error messages now report the exact line and column — not just V8's raw 'position N' byte offset that tells you nothing unless you count characters manually. Paste a broken payload, and you'll see something like 'line 47, column 12' instead of 'position 1843'. That's the difference between finding the bug in five seconds and scrolling for two minutes. The position is extracted from the native JSON.parse error, so it's accurate to the byte.
You can also download the formatted output as a timestamped .json file — handy when you're passing a cleaned payload to a colleague or archiving a snapshot of an API response. The filename includes the date and time so you don't end up with five files named 'output.json'. No upload involved: the file is generated in-browser and saved directly to your downloads folder.
Frequently Asked Questions
What exactly is JSON?
Why bother formatting JSON?
Is my data sent to a server?
What does the depth stat mean?
What is the difference between JSON and XML?
Can I format very large JSON files?
You might also need
See all tools →Complementary tools based on what you're doing