Browser-local code formatter

JSON Formatter

Format, minify, and validate JSON in your browser, with the line and column reported when the input is broken.

JSON Formatter

Processed in this browser
Paste JSON
Ready to copy

How to use it

A short path from source data to a usable local result.

01

Add JSON

Paste or upload a document, even one that arrived on a single line.

02

Pick an action

Format indents it, Minify removes whitespace, Validate only checks it.

03

Take the result

Copy the text or download it as formatted.json.

Common questions

Details that matter when moving data between formats.

How much indentation is used?

Two spaces. The output comes from JSON.stringify, so key order is exactly the order in the input.

Where does the error position come from?

The parser reports a character position and the page converts it to a line and a column, so the message points at the exact spot.

Does formatting change my data?

No. Numbers, strings, and key order are written back as they were parsed; only whitespace changes.

Can it handle a large file?

Up to the memory the tab can hold. A file of several megabytes may pause the page while it is parsed.

Related tools

Other focused converters that are already available.

When is JSON Formatter useful?

A JSON formatter earns its place when a response arrives on one line, when a config file has been edited by three different tools, or when a diff has to show what actually changed. Putting each key on its own line with two spaces of indentation turns a wall of text into something a person can read, and it makes a version-control diff meaningful instead of a single changed line. The work happens in the tab: the text is parsed by the same parser that backs JSON.parse, formatted, and written back. Nothing is uploaded, which matters when the payload holds tokens, customer records, or internal configuration.

Three actions cover most of the work. Format indents the document with two spaces and keeps key order exactly as it appeared. Minify removes every optional space and newline so the payload is as small as it can be before it is sent. Validate parses the document and reports the top-level type and its size without producing output. Because the page uses the browser parser rather than a permissive one, what it accepts is exactly what the browser would accept: no comments, no trailing commas, no unquoted keys, and no single-quoted strings.

Errors are the part that usually costs time, so the message is built to point at the spot. The parser reports a character position and the page converts that position to a line and a column, so a misplaced comma in a two-thousand-line file is a jump rather than a search. The common causes are a trailing comma before a closing bracket, a value pasted without its quotes, and a document that is actually two objects stacked on top of each other. A very large file is held in memory while it is parsed, so the page can pause for a moment before the result appears.