DEV-001
JSON Formatter
Paste JSON to reformat it with consistent indentation, collapse it to a single line, or find out exactly where it is invalid. Parsing happens in your browser, so API responses and payloads stay on your machine.
- Free
- No signup
- Private · runs locally
How to format JSON
- Paste your JSON into the editor.
- Press Format to indent it, or Minify to strip every unnecessary character.
- If the JSON is invalid you get the reason and the position of the problem instead of a result.
- Copy the output when you are done.
Common JSON errors
Trailing commas are the most frequent cause. JavaScript object literals tolerate them; JSON does not, so {"a": 1,} is invalid.
Keys and strings must use double quotes. Single quotes are valid JavaScript but not valid JSON, and unquoted keys are rejected outright.
JSON has no comments. Anything after // or inside /* */ makes the whole document invalid, which catches people out when copying from a config file.
Values must be a string, number, boolean, null, object or array. NaN, Infinity and undefined cannot appear in valid JSON.
Formatting parses and re-prints, which changes three things
The document is parsed into a value and printed again, rather than being tidied as text. That is what makes the validation trustworthy, and it has consequences worth knowing before you paste the output back over the original.
Numbers are re-serialised. 1.0 comes back as 1, 1e3 comes back as 1000, and an integer longer than about 16 digits loses precision: 12345678901234567890 comes back as 12345678901234567000. If your identifiers are long numbers, they belong in strings, and this is the tool that will show you why.
Key order is mostly preserved, with one exception that surprises everyone. Keys that look like integers are moved to the front and sorted numerically, so {"2": "b", "1": "a"} comes back with 1 first. That is the language's rule for object keys, not a choice made here.
Duplicate keys collapse silently and the last one wins, because a parsed object can only hold each key once. A document with a repeated key is legal JSON that different parsers disagree about, so seeing it disappear here is a warning rather than a bug.
What the error message tells you
An invalid document reports the reason along with a line and a column rather than the raw character offset the browser gives, because counting to character 1,847 by hand is not a diagnostic.
The position is where the parser gave up, which is usually just after the real mistake. A missing comma is reported at the start of the next key, and an unclosed bracket is reported at the end of the document, so read backwards from the position rather than staring at it.
The indentation is two spaces and there is no option for four or for tabs. One house style here keeps diffs quiet; your editor's formatter is the right place to apply your project's own.
Frequently asked questions
Is my JSON sent to a server?
No. The tool uses your browser's built-in JSON parser. Nothing is transmitted, which makes it safe for payloads containing internal data.
What does minifying JSON do?
It removes all whitespace and line breaks. The data is identical, but the payload is smaller - useful for storage and network transfer.
Can it repair broken JSON automatically?
No. It tells you precisely what is wrong and where, but it will not guess at your intent, because guessing wrong silently corrupts data.
Related tools
Other tools people use alongside the JSON Formatter.
- DEV-002Base64 Encoder & DecoderEncode text to Base64 or decode Base64 back to text.Open
- TXT-001Word CounterCount words, characters, sentences and reading time as you type.Open
- TXT-002Case ConverterConvert text to uppercase, lowercase, title case or sentence case.Open
- MKT-001UTM BuilderBuild correctly encoded UTM tracking links for your campaigns.Open
Browse all developer tools or see every tool.