About the JSON Formatter

JSON (JavaScript Object Notation) is the standard data format for web APIs. It represents data as key-value pairs, arrays, and nested objects. Every modern programming language has built-in JSON support, and virtually every REST API returns JSON. Formatting makes raw API responses readable; minifying reduces payload size for production.

Pretty-print vs Minify vs Smart Format

Common JSON validation errors

The most frequent JSON mistakes are: trailing commas after the last item in an object or array, single quotes instead of double quotes around strings, unquoted key names, JavaScript-style comments (JSON has no comment syntax), and undefined or NaN values which are not part of the JSON specification.

JSON in APIs and configuration

JSON is the default response format for REST APIs, the configuration format for package.json, tsconfig.json, and .eslintrc, and the storage format for NoSQL databases like MongoDB. Understanding how to read, format, and validate JSON is one of the most practically useful skills for any developer or technical professional.

Frequently Asked Questions

Why is my JSON invalid?
The most common causes are trailing commas (e.g. {"a":1,} is invalid), single quotes instead of double quotes, unquoted keys, comments (JSON does not support // or /* */), and values like undefined or NaN which are not JSON data types. This formatter shows the exact line and character of the error.
What is the difference between JSON and a JavaScript object?
JSON is a strict text format: all keys must be double-quoted, values must be strings, numbers, booleans, null, arrays, or objects. JavaScript objects are more flexible: unquoted keys, single quotes, functions, undefined, and comments are all valid. JSON is a strict subset of JavaScript literal syntax.
How do I pretty-print JSON on the command line?
Python: echo '{"a":1}' | python3 -m json.tool. jq: cat file.json | jq .. Node.js: node -e "console.log(JSON.stringify(require('./file.json'),null,2))".
What does the Sort Keys feature do?
It recursively sorts all object keys alphabetically throughout the entire JSON structure, then formats the result. This is useful for normalising API responses, making two similar JSON objects easier to compare visually, and producing deterministic output from different data sources.
How do I load JSON from a URL?
Paste the URL into the "Load from URL" field at the top and click Fetch. This works for any publicly accessible JSON endpoint. Note that some APIs block cross-origin requests (CORS), in which case the fetch will fail and you will need to copy the response manually.
Related tools
Ad