internettoolbox
← Back to Tools

JSON Formatter

How it works

Paste or type JSON into the input area. Click Format to pretty-print it with proper indentation, Minify to compress it to a single line, or switch to the Tree View to expand and collapse nested objects and arrays interactively. Invalid JSON is flagged with an error message and, where possible, a line number pointing at the exact character that broke the parser.

The formatter uses the browser's native JSON parser (JSON.parse / JSON.stringify), so it accepts the exact same dialect that your backend, your browser, and your tests accept. Duplicate keys collapse to the last value (per spec), keys must be double-quoted strings, trailing commas are rejected, and comments are not allowed. If what you have is really JSON5 or JSONC, the tool reports the specific error rather than guessing at what you meant.

Common things the formatter helps with: inspecting an API response that arrived as a single-line string, spotting the missing closing brace in a hand-written config, converting between a formatted "readable" version and a minified "production" version before pasting into a URL or an environment variable, and exploring a deeply nested payload without writing a script. It all runs in your browser, so a payload with customer data or an auth token in it never leaves the tab.

Frequently Asked Questions

What happens if my JSON is invalid?

You get the native parser error message plus the position (line and column, where possible) of the first character that broke parsing. Fix that one and re-run: JSON errors are usually local, so the next parse either succeeds or points at the next mistake further down.

Can I view nested objects?

Yes, in the Tree View, which expands and collapses nested objects and arrays to any depth. That beats scrolling through 2,000 lines of indented text. Keys are sorted stably, and the current node's JSON path is displayed when you click it.

Does it handle big JSON files?

Files up to a few MB are handled comfortably on any modern laptop, because the limit is your browser's memory rather than a server. For very large payloads (tens of MB or more) you may hit a slow parse or the browser's tab-size limit, and a streaming parser in Node or Python is the better fit.

Does it preserve key order?

Yes. Format and minify keep keys in the order they were parsed, because native JSON.stringify preserves insertion order. The Tree View sorts keys alphabetically for easier scanning, but that sort applies only to the visual tree, not to the formatted output.

Are comments or trailing commas supported?

No, because the JSON spec does not allow either. A file with // line comments or a trailing comma before ] or } is rejected by the parser. What you are looking at is JSON5 or JSONC: strip the offending characters or use a dedicated JSON5 parser.

How much smaller is minified JSON?

Around 20–40% smaller than pretty-printed JSON, because minifying strips the whitespace. That is what you want when you have to paste JSON into an environment variable, a URL query string, or a config field with a length limit, or when you are sending it over the wire and want to save a few kilobytes.

Tool switcher

Search and jump to any tool