JSON formatter & validator

Beautify, minify and validate JSON. Spot the error line instantly.

Runs entirely in your browser. Your JSON is never sent to a server.

Have feedback or an idea for this tool?

What does a JSON formatter do?

JSON is the text format most APIs and configuration files use to exchange structured data, and it is easy to break with a missing comma, bracket or quote. This tool beautifies JSON by adding consistent indentation so nested structures are readable, minifies it by stripping whitespace to shrink payloads, and validates it by parsing the text and pointing to the exact place a syntax error occurs. Everything runs in your browser, so the data you paste is never sent to a server. Paste JSON and choose an action. Use it to make an API response readable while debugging, to catch the specific line breaking a config file, or to compact a document before storing or transmitting it. Because validation happens locally, it is safe to check payloads that contain sensitive values.

Key facts

  • JSON is defined by RFC 8259, requiring double-quoted strings and keys, and allowing only the lowercase literals true, false and null.
  • Formatting JSON adds indentation and line breaks for readability, while minifying strips insignificant whitespace, and both produce the same parsed value.
  • Standard JSON does not allow comments (// or /* */) or a trailing comma after the last array element or object member.
  • A trailing comma before a closing bracket or brace is one of the most common causes of invalid JSON.
  • Whitespace outside of string values has no meaning in JSON, so beautifying and minifying a document are lossless operations.

Format, minify or validate JSON in one pass

Paste raw JSON and the tool parses it, reports whether it is valid, and reprints it. Formatting (also called beautifying or pretty-printing) adds line breaks and consistent indentation so nested objects and arrays are easy to scan. Minifying does the opposite: it strips every space, tab and newline that sits between tokens, producing the smallest byte-equivalent output for transport or storage.

Both operations are lossless. Whitespace outside of string values carries no meaning in JSON, so a beautified document and its minified form parse to exactly the same value. Use formatting when you are reading or diffing a payload, and minify when you are shipping it over the wire or embedding it in a config.

JSON syntax rules the validator enforces

JSON is defined by RFC 8259 and json.org, and the grammar is strict. Strings and object keys must use double quotes, never single quotes, and keys are always quoted. Numbers use a JSON literal form (no leading zeros, no hex, no NaN or Infinity). The only allowed literals are true, false and null, all lowercase.

Trailing commas are not allowed after the last element of an array or the last member of an object. Comments are not part of JSON at all, so // and /* */ will fail even though many editors tolerate them in config files. If you need comments, you are working with JSON5 or JSONC, not standard JSON, and those will not pass a strict parser.

RFC 8259 (the JSON spec) · json.org grammar

Reading validation errors

When parsing fails the tool surfaces the underlying error and points at the position where it broke. The most common message developers hit is "Unexpected token", which means the parser found a character it could not use in that spot - often a stray comma, a single quote, an unquoted key, or a value that was never closed.

A trailing comma before a closing bracket or brace is the single most frequent cause of invalid JSON, especially when a payload is hand-edited or assembled by string concatenation. Other repeat offenders are missing commas between elements, missing closing brackets, and control characters that were not escaped inside a string. The reported line and column narrow the search to a few characters.

Runs in your browser - safe for real payloads

All parsing, formatting, minifying and validation happen locally in your browser using the native JSON engine. Nothing you paste is uploaded to a server or logged, so you can safely work with API responses, environment configs, webhook bodies or other sensitive data without it leaving your machine.

That matters for anyone handling production data. ServerCake runs developer infrastructure in India, and we keep these small tools client-side on purpose so an internal token or customer record never travels to a third party just to be pretty-printed.

Glossary

JSON (JavaScript Object Notation)
JSON is a text data format, defined by RFC 8259, that represents structured data as objects, arrays, strings, numbers and the literals true, false and null. Strings and object keys must be wrapped in double quotes.
Beautify (pretty-print)
Beautifying reprints JSON with line breaks and consistent indentation so nested objects and arrays are readable. It changes only whitespace, so the parsed value is identical to the compact form.
Minify
Minifying strips every space, tab and newline between tokens to produce the smallest byte-equivalent JSON for transport or storage. Because whitespace outside strings has no meaning, the operation is lossless.
Validation
Validation parses text against the JSON grammar and reports whether it is well-formed. Common failures include trailing commas, single quotes instead of double quotes, unquoted keys and unclosed brackets.
Trailing comma
A trailing comma is a comma left after the last element of an array or last member of an object. Standard JSON forbids it, and it is one of the most frequent causes of an invalid document.
JSON5 / JSONC
JSON5 and JSONC are relaxed supersets of JSON that permit comments and trailing commas. They are separate formats and will fail a strict RFC 8259 parser.

Questions, answered.

Is my JSON sent to a server?+

No. Formatting, validation and minifying all happen in your browser using the native JSON engine, so you can safely paste config, tokens or API data without it leaving your machine.

What is the difference between formatting and minifying?+

Formatting (beautifying) adds indentation and line breaks so the JSON is easy to read. Minifying strips all whitespace between tokens to make the payload as small as possible for transport. Both produce the same parsed value - only the whitespace differs.

Why does it say my JSON is invalid?+

The most common causes are a trailing comma before a closing bracket or brace, single quotes instead of double quotes, unquoted keys, comments (// or /* */, which JSON does not allow), or a missing bracket. The validator points to where parsing failed so you can fix that spot.

What does the error 'Unexpected token' mean?+

It means the parser reached a character it cannot use in that position - typically a stray or trailing comma, a single quote, an unquoted key, or a value that was never closed. The reported line and column tell you where to look.

Is this a JSON validator as well as a beautifier?+

Yes. Every format or minify pass first parses the input against the JSON grammar from RFC 8259, so an invalid document is reported before it is reprinted. It works as a validator, formatter, beautifier and minifier in one tool.

Can I change the indentation of the output?+

Yes. You can pretty-print with 2-space or 4-space indentation. Two spaces is the most common convention for JSON files and API payloads, while four spaces is sometimes used to match a wider codebase style.

Are comments or trailing commas allowed in JSON?+

No. Standard JSON, as defined by RFC 8259, does not allow comments (// or /* */) or trailing commas after the last item. If you need those, you are using JSON5 or JSONC, which are separate formats and will not pass a strict JSON parser.

Can this convert JSON to CSV or view it as a tree?+

This tool focuses on formatting, validating and minifying JSON text. It does not convert JSON to CSV or render an interactive tree viewer; for those, format the JSON here first so it parses cleanly, then feed the valid output into a dedicated converter or viewer.

Built by the ServerCake team

Cloud that speaks India.

These tools run on ServerCake infrastructure in India. When our cloud opens, you get VMs and managed databases priced in ₹, billed with GST, on India-resident infrastructure. Reserve your spot for early access.

Reserve your spot