🧩 JSON Formatter and Validator
By ToolNimba Web Dev Team · Updated 2026-06-19
Paste JSON above, then choose Format, Minify, or Validate.
This JSON formatter cleans up messy JSON in one click. Paste your data and choose Format to pretty-print it with neat indentation, Minify to strip every space and newline into a single compact line, or Validate to confirm it parses and see the exact error if it does not. Everything runs in your browser, so your data never leaves the page, which matters when you are pasting API responses or config that might be sensitive.
What is the JSON Formatter?
JSON (JavaScript Object Notation) is the most common format for sending structured data between programs: API responses, config files, log records and database documents are usually JSON. It is built from a few simple pieces: objects in curly braces with "key": value pairs, arrays in square brackets, strings in double quotes, numbers, the literals true, false and null, all nested as deeply as you like. A formatter does not change what the data means, it only changes the whitespace so a human can read it.
Formatting (also called beautifying or pretty-printing) adds line breaks and indentation so the nesting is visible at a glance. Minifying does the opposite: it removes all the optional whitespace to make the payload as small as possible, which is what you want when sending JSON over a network. Because whitespace outside of strings is not significant in JSON, the two forms are exactly equivalent to a parser, the same object can round-trip from pretty to minified and back without losing anything.
Validating is the step people skip and then regret. A single trailing comma, a missing quote, or a stray curly brace makes the whole document unparseable, and the error a server returns is often vague. This tool uses the browser’s own JSON.parse, the same strict parser your JavaScript code uses, so if it accepts your text then any standards-compliant parser will too. When parsing fails it shows you the engine’s own message, which usually names the position or token that broke, so you can jump straight to the problem.
When to use it
- Reading a minified API response by expanding it into readable, indented JSON.
- Shrinking a formatted config or payload to one line before sending it over the network or pasting into a single-line field.
- Checking whether a hand-edited config file is valid JSON before deploying it.
- Pinpointing a syntax error (a stray comma or missing quote) from the exact parser message.
- Tidying JSON copied from logs or a chat so it is easy to scan during debugging.
How to use the JSON Formatter
- Paste or type your JSON into the input box.
- Pick an indent size (2 spaces, 4 spaces or a tab) if you plan to format.
- Click Format to pretty-print, Minify to compress to one line, or Validate to just check it.
- Read the status line: it confirms valid JSON or shows the exact parse error.
- Click Copy to put the result on your clipboard.
Formula & method
Worked examples
You paste the minified object {"name":"Ada","tags":["math","code"]} and click Format with a 2-space indent.
- The tool runs JSON.parse on the text, which succeeds, giving an object.
- It then runs JSON.stringify(value, null, 2) to add line breaks and indentation.
- Each key sits on its own line, and the array items are indented one level deeper.
Result: { "name": "Ada", "tags": [ "math", "code" ] }
You paste {"a": 1, "b": 2,} (note the trailing comma) and click Validate.
- JSON.parse rejects the trailing comma, because JSON does not allow it.
- The parser throws a SyntaxError naming the position of the bad token.
- The tool shows the message instead of any output, so you know exactly what to fix.
Result: Invalid JSON: a message like "Unexpected token } in JSON at position 16". Remove the comma after 2.
JSON value types and how they are written
| Type | Example | Notes |
|---|---|---|
| Object | { "key": "value" } | Keys must be double-quoted strings. |
| Array | [ 1, 2, 3 ] | Ordered list, any value types, no trailing comma. |
| String | "hello" | Double quotes only, never single quotes. |
| Number | 42, -3.14, 1e6 | No leading zeros, no NaN or Infinity. |
| Boolean | true, false | Lowercase only. |
| Null | null | Lowercase, represents an empty value. |
Common JSON mistakes the validator will reject
| Mistake | Wrong | Correct |
|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comment | {"a": 1} // note | {"a": 1} |
| Leading zero | {"n": 007} | {"n": 7} |
Common mistakes to avoid
- Leaving a trailing comma. JSON forbids a comma after the last item in an object or array, even though JavaScript object literals allow it. Remove the final comma before the closing bracket or brace.
- Using single quotes. JSON strings and keys must use double quotes. Single quotes are valid in JavaScript but not in JSON, so {'a': 1} fails while {"a": 1} works.
- Forgetting to quote object keys. Every key in a JSON object is a string and must be wrapped in double quotes. {name: "Ada"} is invalid, {"name": "Ada"} is correct.
- Adding comments. Standard JSON has no comment syntax. Lines starting with // or /* */ will cause a parse error. Strip comments, or use a format like JSON5 that is not interchangeable here.
- Pasting a JavaScript object instead of JSON. Code with unquoted keys, single quotes or trailing commas is a JavaScript literal, not JSON. Convert it to strict JSON before formatting.
Glossary
- JSON
- JavaScript Object Notation, a text format for representing structured data as objects, arrays and primitive values.
- Beautify / pretty-print
- Adding line breaks and indentation so nested JSON is easy for a human to read.
- Minify
- Removing all optional whitespace so the JSON is as small as possible for storage or transfer.
- Validate
- Checking that text is well-formed JSON that a parser will accept, and reporting any syntax error.
- Parse
- Reading JSON text and turning it into an in-memory value such as an object or array.
- Indent
- The number of spaces (or a tab) used at each nesting level when pretty-printing.
Frequently asked questions
How do I format JSON online?
Paste your JSON into the input box and click Format. The tool parses it and re-prints it with line breaks and your chosen indentation (2 spaces, 4 spaces or a tab). It runs entirely in your browser, so nothing is uploaded.
What is the difference between formatting and minifying JSON?
Formatting (beautifying) adds whitespace and indentation to make JSON readable. Minifying removes all optional whitespace to make it as small as possible. Both produce identical data to a parser, since whitespace outside of strings is not significant in JSON.
How do I know if my JSON is valid?
Click Validate. The tool runs the browser’s strict JSON.parse on your text. If it parses, you see a confirmation and the top-level type. If not, you see the exact parser error message, which usually names the position or token that broke.
Why does my JSON say it is invalid?
The most common causes are a trailing comma, single quotes instead of double quotes, unquoted object keys, comments, or a missing bracket. The error message points to the offending position so you can fix it quickly.
Is my data sent to a server?
No. All parsing, formatting and minifying happen in your browser with JavaScript. Your JSON never leaves the page, which makes the tool safe for sensitive API responses or config.
Can JSON have comments?
No. Standard JSON has no comment syntax, so // or /* */ will cause a parse error. If you need comments, use a superset like JSON5 or JSONC, but remove them before using strict JSON parsers or APIs.