Prettify, minify, and validate JSON instantly in your browser. Syntax errors are detected and reported with the exact line and character position. Choose from 2-space, 4-space, or compact indentation. All processing happens locally โ your data never leaves your machine.
JSON (JavaScript Object Notation) is the dominant data interchange format on the modern web. Created by Douglas Crockford in the early 2000s, it has replaced XML in most REST API contexts because it is lighter, more readable, and maps directly to data structures in virtually every programming language. Today, JSON is used in API responses, configuration files, database storage (MongoDB, CouchDB, PostgreSQL's JSONB), log files, and as a general-purpose data exchange format between services.
Raw JSON from APIs and services is often compact โ all whitespace is removed to reduce payload size. This is ideal for network transmission but completely unreadable when you need to inspect or debug the data. A formatter adds consistent indentation and line breaks to transform a wall of text into a structured, readable document while preserving the exact data content.
This tool uses the browser's native JSON.parse() and JSON.stringify() functions to process your JSON. Parsing validates the syntax and builds an in-memory representation of the data structure. Stringify then serialises it back to text with the specified indentation level. This approach has several advantages: it is extremely fast even for large JSON documents, it always produces standards-compliant output, and it normalises the JSON (fixing minor inconsistencies in spacing around colons and commas).
For error reporting, when JSON.parse() fails it throws a SyntaxError with a message that includes the position of the error. This tool parses that error message to report the exact line and character where the problem was found, making it much faster to locate and fix syntax issues than manually searching through a large document.
For human-readable configuration files and documentation, 2-space indentation is the most widely adopted standard โ it is used by npm, Google's style guide, and most linting tools. 4-space indentation is common in Python-influenced projects and provides slightly more visual separation at the cost of line length. Compact (minified) JSON is appropriate for production API responses and any context where bandwidth matters. Never use tab indentation in JSON files shared between different editors and systems โ tab width varies by environment and can cause visual inconsistencies.
The most frequent JSON errors developers encounter are: trailing commas after the last item in an object or array (valid in JavaScript but invalid in JSON), single-quoted strings (JSON requires double quotes), unquoted property names (also valid in JavaScript but invalid in JSON), comments (JSON has no comment syntax), and special characters in strings that need to be escaped with a backslash. If this formatter reports a syntax error, check the indicated line for these common mistakes first.
Format JSON programmatically via the Toolpad REST API:
POST https://api.toolpad.in/api/v1/datatools/format/json
Request body: {"input": "your json string", "indent": 2}