Format, validate, and minify JSON instantly — with syntax highlighting and exact error location.
Format messy JSON with syntax highlighting, validate and find errors with exact line numbers, minify for production, and explore structure with stats. Free, runs in your browser, no data sent to any server.
By Imtiaz Ali | OurToolkit | Updated June 2026
JSON — JavaScript Object Notation — is a text-based data interchange format specified in ECMA-404 and RFC 8259. It was popularised by Douglas Crockford in the early 2000s as a simpler alternative to XML for transmitting data between web clients and servers. Despite its name containing "JavaScript," JSON is completely language-independent and is natively supported in every major programming language including Python, Java, PHP, Ruby, Go, Rust, Swift, Kotlin, and C#. When JSON payloads contain URLs or special characters, use our URL encoder/decoder to safely process them.
JSON has become the de facto standard for REST API responses, webhook payloads, configuration files, and NoSQL database documents. It powers the data layer of virtually every modern web and mobile application. When a weather app fetches the current temperature, when your browser loads your Twitter timeline, when an e-commerce site processes an order — JSON is almost certainly the format carrying that data. API authentication often involves Base64-encoded credentials in JSON payloads.
The format's dominance comes from three qualities: it is genuinely human-readable when formatted, it maps naturally to the data structures found in virtually every programming language (objects/dictionaries and arrays/lists), and it is significantly more compact than XML for equivalent data structures.
JSON has exactly six data types and a small set of syntax rules. Unlike programming languages, it has no flexibility or forgiveness — a single character out of place makes the entire document invalid. Understanding these rules is the difference between wasting time debugging and fixing errors in seconds.
| Type | Syntax | Valid example | Common mistake |
|---|---|---|---|
| String | Double-quoted text | "Hello World" | Using single quotes: 'Hello' |
| Number | Integer or decimal | 42 or 3.14 | Using NaN or Infinity |
| Boolean | Lowercase only | true or false | Capitalised: True |
| Null | Lowercase only | null | Capitalised: Null or NULL |
| Object | Key-value pairs in {} | {"key": "value"} | Unquoted keys: {key: "value"} |
| Array | Ordered list in [] | [1, 2, 3] | Trailing comma: [1, 2, 3,] |
A JSON object is a collection of key-value pairs enclosed in curly braces. Every key must be a string enclosed in double quotes (use our URL encoder to properly encode keys containing special characters). Keys and values are separated by a colon. Pairs are separated by commas. The final pair must not have a trailing comma. An empty object is valid: {}.
A JSON array is an ordered list of values enclosed in square brackets. Values can be of any JSON type and can be mixed types within the same array. Values are separated by commas. The final value must not have a trailing comma. An empty array is valid: []. Arrays can be nested inside objects and objects can be nested inside arrays to any depth.
Every developer who works with JSON regularly has encountered the same set of errors repeatedly. The JSON validator in this tool detects all of these and shows the exact position where the error occurs. When debugging JSON errors from URL-encoded parameters or Base64-encoded payloads, decode them first using our specialized tools, then validate with this formatter.
| Error type | Invalid example | Fixed example | Why it fails |
|---|---|---|---|
| Single quotes | {'name': 'Alice'} |
{"name": "Alice"} |
JSON requires double quotes for all strings and keys. Single quotes are only valid in JavaScript, not JSON. |
| Trailing comma | {"a": 1, "b": 2,} |
{"a": 1, "b": 2} |
JSON does not allow a comma after the last element in an object or array. JavaScript allows this; JSON does not. |
| Comments | {"a": 1 // comment} |
{"a": 1} |
JSON does not support comments of any kind. Remove all // and /* */ comments before parsing. |
| Unquoted key | {name: "Alice"} |
{"name": "Alice"} |
All JSON keys must be strings enclosed in double quotes. Unquoted keys are JavaScript object syntax, not JSON. |
| Undefined value | {"a": undefined} |
{"a": null} |
JSON has no undefined type. Replace undefined values with null or omit the key entirely. |
| NaN / Infinity | {"ratio": NaN} |
{"ratio": null} |
JSON numbers do not support NaN (Not a Number) or Infinity. These are JavaScript-specific numeric values. |
| Unescaped quotes | {"msg": "say "hi""} |
{"msg": "say \"hi\""} |
A double quote inside a string value must be escaped with a backslash. Otherwise the parser thinks the string has ended. |
| Unescaped newline | {"line": "first |
{"line": "first\nsecond"} |
Literal newline characters inside strings are not allowed. Use the escape sequences \n (newline), \t (tab), \r (carriage return). |
| Duplicate keys | {"a": 1, "a": 2} |
{"a": 2} |
Technically not a parse error, but behaviour is undefined — different parsers handle it differently. Most keep the last value. Avoid duplicate keys entirely. |
Formatted (pretty-printed) JSON and minified JSON contain identical data — the only difference is whitespace. The choice between them is purely contextual. Understanding the tradeoffs helps you optimize your applications and APIs. For JSON transmitted via URLs, remember to use our URL encoder to safely escape the formatted or minified string.
Use formatted JSON when humans need to read and understand the data. The primary use cases are during development (reading API responses, inspecting data structures, writing configuration files manually), in version control (formatted JSON diffs are readable in git; minified JSON diffs are essentially unreadable), in documentation (code examples in API documentation should always be formatted), and in debugging sessions where you need to understand a complex nested structure.
Use minified JSON in production environments where transfer speed and file size matter. A well-written API should return minified JSON in production responses. The size reduction from minification is typically 20–40% depending on how deeply nested and string-heavy the data is. For a response that is called thousands of times per day, this translates to meaningful bandwidth savings and faster response times. This is especially important when your API is accessed over cellular networks or when you're optimizing page performance alongside other tools like CSS minifiers.
Understanding how JSON compares to other data formats helps you choose the right format for your project. When working with multiple formats, you may need to convert between them or process them using specialized tools. Our URL encoder/decoder helps when any of these formats are transmitted through URLs or APIs.
| Feature | JSON | XML | CSV |
|---|---|---|---|
| Verbosity | Low — minimal syntax overhead | High — opening and closing tags | Minimal — commas only |
| Readability | High when formatted | Moderate — tags clutter content | Low for nested data |
| Data types | 6 native types | String only (types must be parsed) | String only |
| Hierarchical data | Excellent — nested objects/arrays | Excellent — nested elements | None — flat only |
| Parse speed | Fast | Slow — more markup to parse | Very fast |
| Schema validation | JSON Schema, OpenAPI | XSD, DTD (mature ecosystem) | Limited |
| Comments | Not supported | Supported | Not standardised |
| Browser native support | Yes — JSON.parse() | Yes — DOMParser | No — requires library |
| Best for | APIs, config, NoSQL | Document markup, SOAP, SVG | Tabular data, spreadsheets |
This online tool is ideal for one-off formatting and debugging. For programmatic formatting in your codebase, here is the correct approach in every major language. When JSON is transmitted in URLs (such as API parameters), use our URL encoder to safely escape the formatted JSON string.
JSON.stringify() accepts a third argument for indentation. Pass a number for space-based indentation or a string (e.g. "\t") for tab-based indentation. The second argument is a replacer — pass null to include all properties.
Python's built-in json module handles formatting via the indent parameter of json.dumps(). Use sort_keys=True to alphabetically sort keys — useful for consistent diffing in version control.
jq is the standard command-line JSON processor. It formats JSON by default and supports powerful filtering, transformation, and querying of JSON data.
Basic JSON validation (which this tool performs) only checks that the JSON is syntactically correct. JSON Schema goes further — it validates that a JSON document has the correct structure, the right data types for each field, required keys, value constraints (minimum, maximum, pattern matching), and more. JSON Schema is particularly important in API development where you need to guarantee that client-submitted data matches the expected format before processing it. For API requests, always validate JSON payloads here first, then use our URL encoder if you're passing JSON as query parameters, or our Base64 encoder for encoding binary data embedded in JSON. Here is a simple JSON Schema example for validating a user object:
JSONPath is a query language for JSON that lets you extract specific values from a complex nested structure using path expressions. It is similar in concept to XPath for XML and is supported in libraries for JavaScript, Python, Java, PHP, and most other major languages. When combined with our URL encoder, JSONPath queries can be safely transmitted in API URLs.
Common JSONPath expressions: $.name extracts the root-level "name" property. $.users[0].email extracts the email of the first user. $.users[*].name extracts all user names. $.store..price extracts all prices anywhere in the store object using deep scan. JSONPath is widely used in API testing tools (Postman uses JSONPath for test assertions), configuration management tools, and data pipeline transformations.
JSONC is an extension of JSON that supports JavaScript-style comments (// and /* */). It is used in configuration files where comments explaining settings are important — most notably in tsconfig.json (TypeScript compiler configuration) and VS Code's settings.json. JSONC files are not valid standard JSON and cannot be parsed by standard JSON parsers — they require a JSONC-aware parser. If you paste JSONC into this tool, it will show as invalid because this tool uses the standard JSON specification. For data that needs to be transmitted via URL parameters, convert to standard JSON first.
JSON5 is a more relaxed superset of JSON designed for hand-written configuration files. In addition to JSONC comments, JSON5 also allows: single-quoted strings, unquoted object keys (if they are valid JavaScript identifiers), trailing commas in objects and arrays, hexadecimal numbers (0xFF), and multi-line strings. JSON5 is used by Babel configuration files, some ESLint configurations, and build tools. Like JSONC, it is not valid standard JSON and requires a dedicated parser. When sharing JSON5 configs with other developers, consider converting to standard JSON using this formatter, then share via URL-encoded link parameters or Base64-encoded content.
REST APIs almost universally use JSON as their data interchange format. A typical REST API response includes a Content-Type: application/json header and returns a minified JSON body. When building or consuming REST APIs, correctly formatted JSON is critical — sending malformed JSON in a request body will cause the server to return a 400 Bad Request error. Before debugging why an API integration is failing, paste the request body into this formatter to verify it is valid JSON. When working with query parameters in APIs, use our URL encoder to properly format API endpoint parameters.
Webhooks send JSON payloads to your endpoint via HTTP POST when events occur — for example, when a Stripe payment completes, when a GitHub push is made, or when a Shopify order is placed. The payload is always minified JSON for efficient transmission. When debugging a webhook that is not processing correctly, copy the raw webhook body and paste it into this formatter to inspect the structure and identify which fields contain the data you need. If the webhook includes encoded data (such as Base64-encoded authentication tokens or URL-encoded parameters), decode them using our specialized tools.
GraphQL APIs always return JSON, even when the request uses GraphQL query language syntax. The response always has the structure {"data": {...}, "errors": [...]}. The data field contains the requested data (or null on error). The errors field is omitted when there are no errors. Formatting GraphQL responses with this tool makes it much easier to understand which part of the nested data structure corresponds to which part of your query. For APIs using authentication, ensure your API keys and bearer tokens are properly encoded using our Base64 encoder when needed.