JSON Formatter
Format, minify, repair and validate JSON online for free. All data is processed locally in your browser.
This tool runs entirely in your browser. Your input is never uploaded.
What is JSON formatting?
JSON formatting parses raw JSON and applies consistent indentation and line breaks to make it easier to read. This tool can also remove unnecessary whitespace to produce compact JSON, and it can repair the syntax mistakes that stop JSON.parse from accepting an otherwise complete document.
How to use it
- Paste JSON into the editor, or upload a
.jsonfile. - Choose two or four spaces for indentation.
- Select Format for readable output, Minify for compact output, or Repair to fix broken JSON.
- Copy the result when you are done.
Repairing broken JSON
JSON that a server or browser rejects is often one character away from valid. Repair parses the document leniently, applies the fixes below, and reports which ones it applied.
| Problem | Example | Result |
|---|---|---|
| Missing comma | {"a": 1 "b": 2} | Inserts the comma |
| Trailing comma | {"a": 1,} | Removes it |
| Comments | // note or /* note */ | Removed |
| Unquoted keys | {id: 1} | "id": 1 |
| Single-quoted strings | {'a': 'b'} | "a": "b" |
undefined | {"a": undefined} | null |
| Raw newlines in strings | "line1⏎line2" | Escaped as \n |
| Python literals | True, False, None, NaN | true, false, null |
Repairs are applied in the course of parsing rather than by rewriting the text, so a // inside a string such as "https://example.com" is never mistaken for a comment. When the input is already valid, the result is identical and the tool says no repairs were needed.
A missing comma is restored automatically because the intended structure is unambiguous. A missing colon is not: in {"a" 1} it is unclear whether the colon was dropped or two values were intended, so the tool still reports an error rather than guess.
Uploading a file falls back to the repair pass automatically when the file is not strictly valid JSON, so a slightly broken export still loads.
Filtering with JSONPath
The search icon next to JSON opens a JSONPath bar. Type an expression such as $.list[*].title to extract matching values from the document without hand-writing a script. The expression runs against the JSON currently in the editor.
Privacy and security
Your input is processed directly by JavaScript in your browser and is never sent to a server. The tool does not intentionally persist input after you close or refresh the page.
Frequently asked questions
Why does JSON validation fail?
Common causes include unquoted property names, missing or trailing commas, single-quoted strings, undefined values, or unescaped characters inside strings. Most of these are fixed by Repair.
Does formatting or repairing change my data?
Formatting only changes whitespace and indentation. Repairing changes what was already malformed: undefined and Python literals become null, and missing separators are inserted. Objects, arrays, strings, numbers, and booleans keep their original meaning.
Is my JSON sent anywhere?
No. Every operation, including the lenient parse used by Repair, runs locally in your browser.