JSON Formatter
Paste JSON to prettify or minify it. Validation errors are highlighted instantly.
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
- Pretty-print — adds 2-space indentation and line breaks. Use when reading or editing JSON manually.
- Minify — removes all whitespace. Reduces file size by 20-40%, important for API responses served over HTTP.
- Smart format — keeps short arrays and objects on one line, expands complex nested structures. Best readability for real-world data with mixed complexity.
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.
- REST APIs — virtually all modern APIs return JSON; Content-Type: application/json
- npm/Node.js — package.json defines dependencies, scripts, and project metadata
- TypeScript — tsconfig.json controls compilation; extends JSON with comment support (JSONC)
- MongoDB — documents are stored as BSON (Binary JSON); queries and results are JSON-like
Frequently Asked Questions
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))".