JSON Formatter & Validator
Paste your JSON below, then format, minify or validate it. Everything runs locally in your browser — your data never leaves your device.
JSON in one line: it is a text format for structured data built from six value types only — object, array, string, number, true/false and null. Keys and strings must use double quotes, and the document must contain no comments and no comma after the last item.
✅ Quick Answer
{ "a": 1 } is valid. { 'a': 1 }, { a: 1 }, { "a": 1, } and // comment are all invalid — those are JavaScript or JSON5 habits, not JSON.
Rule of thumb: formatting and minifying never change your data — they only add or remove whitespace between tokens. If your document is rejected, it is always a real syntax error, and the validator reports the exact line and column where parsing stopped.
Frequently Asked Questions
What is JSON formatting?
JSON formatting (pretty-printing) adds consistent indentation and line breaks to raw JSON so it becomes easy to read and debug. Raw JSON is often written on a single line; formatting splits it into a clean hierarchical structure.
Is the JSON formatter safe to use with sensitive data?
Yes. Everything runs locally in your browser — your JSON is never uploaded to any server, so it is safe to paste API responses, config files and other sensitive data.
What does minified JSON look like?
Minified JSON removes all unnecessary whitespace, indentation and line breaks, compressing the data into the smallest possible representation. It is commonly used for API payloads where size matters.
How do I fix invalid JSON?
Paste the JSON into the formatter and click Format. If it is invalid, the validator shows the exact line and column of the error with a helpful message, so you can fix typos such as missing commas, unquoted keys or trailing commas.
Is the JSON formatter free to use?
Yes — completely free, works in your browser without any sign-up, and works with JSON of any size that your browser can handle.
How is JSON different from a JavaScript object?
They look alike but follow different rules. JSON is a text format: keys and strings must use double quotes, values are limited to object, array, string, number, boolean and null, and no functions, comments or trailing commas are allowed. A JavaScript object literal is code, so it accepts single quotes, unquoted keys, functions, undefined and comments — but all of that becomes invalid the moment you send it as JSON.
Does JSON allow comments or trailing commas?
No. The JSON specification (RFC 8259) allows neither comments nor a comma after the last member of an object or array. Both are the most common reasons a document is rejected. If you need them, use JSON5 or JSONC, which are supersets designed for configuration files; they must be converted to strict JSON before an API will accept them.
What are JSON5 and JSONC?
JSON5 and JSONC are relaxed supersets of JSON used mainly for hand-written config files. JSON5 adds comments, trailing commas, single quotes, unquoted keys and multi-line strings; JSONC (used by VS Code and TypeScript config) adds comments and trailing commas only. Every valid JSON document is also valid JSON5 and JSONC, but the reverse is not true, so a file that parses in your editor can still be rejected by a strict JSON API.
Does formatting change my data?
No. Formatting and minifying only change whitespace between tokens. Key order, values, number precision and string contents are preserved, and formatting a document then minifying it returns the original bytes. The tool parses your input with the browser's own JSON parser and re-serialises the result, so it can never silently "fix" a value — if the input is invalid, it reports an error instead.
What are the most common causes of invalid JSON?
The usual suspects are a trailing comma before a closing brace or bracket, single quotes around keys or strings, unquoted object keys, // or /* */ comments, the values NaN, Infinity or undefined (none of which exist in JSON), Python-style True/False/None instead of true/false/null, and an unescaped double quote inside a string. All of them are syntax errors, so the validator reports the exact line and column where parsing stopped.
JSON Formatter & Validator — Clean, Debug and Optimize Your JSON
Working with JSON is much easier when you can see its structure at a glance. Our free JSON formatter pretty-prints minified data with clean indentation, validates the syntax with precise error locations, and can minify formatted JSON back down for APIs and storage. No sign-up, no upload, no limits.
Why use our JSON formatter?
- Format messy JSON into a readable tree in one click.
- Validate syntax instantly with exact error line and column numbers.
- Minify formatted JSON for smaller API payloads and storage.
- Choose 2-space, 4-space or tab indentation.
- 100% private — everything runs in your browser.
- Fully free with no registration or usage limits.
Common uses for the JSON tool
- Debugging API responses from REST or GraphQL endpoints.
- Reading and editing configuration files such as package.json or .prettierrc.
- Cleaning up exported data before sharing or analyzing it.
- Minifying JSON before embedding it in code or sending it over the network.
- Learning JSON syntax — see exactly what a valid JSON document looks like.
JSON syntax quick reference
| Type | Example | Notes |
|---|---|---|
| object | {"a":1} | Keys must be double-quoted strings; order is preserved by this tool, but not guaranteed by the spec. |
| array | [1,2] | Ordered list; may mix types, and may be empty. |
| string | "text" | Double quotes only. An inner quote, a backslash or a line break must be escaped with a backslash, so strings containing them stay on one line. |
| number | 123 / 1.5 | No NaN, Infinity, leading zeros or hex literals. |
| boolean | true / false | Lowercase only — True is Python, not JSON. |
| null | null | The only empty value; undefined does not exist in JSON. |
Six value types, nothing else. Anything outside this list — functions, dates, comments — has to be encoded as a string or a number before it can travel as JSON.
Common JSON errors and how to fix them
| Error | Cause | Fix |
|---|---|---|
{"a":1,} | Trailing comma before a closing brace or bracket. | Delete the comma after the last item. |
{'a':1} | Single quotes — valid in JavaScript, not in JSON. | Use double quotes for every key and string. |
// comment | Comments are not part of the JSON grammar. | Remove them, or keep the file as JSONC and strip them before sending. |
{a:1} | Object key written without quotes. | Write it as "a":1. |
NaN / Infinity | Not representable as a JSON number. | Use null, or send the value as a string. |
True / None | Python literals pasted into JSON. | Use lowercase true / false / null. |
Every one of these is a syntax error rather than a data problem, which is why the validator can point at an exact line and column instead of only saying "invalid".
Whether you are a developer debugging an API, a data analyst cleaning a JSON export, or a student learning JSON syntax, this formatter has you covered. It is fast, reliable, and completely free to use every day.
Working with encoded payloads too? Pair this tool with the Base64 Encoder when a JWT or a data URI needs decoding, the URL Encoder when a JSON value has to survive a query string, and the Password Generator before you store any secret. JSON keeps structured data readable — these tools keep it correct.