JSON formatter
Paste JSON from an API response, a config file or a log, and turn it into neatly indented, readable text, or squeeze it onto one line. If it isn't valid, you'll see exactly where the problem is.
Loading the JSON formatter. It needs JavaScript to run in your browser.
Loading the JSON formatter. It needs JavaScript to run in your browser.
How to use the JSON formatter
- Paste your JSONinto the input box, or press “Try an example” to see how it works.
- Press Formatto indent it with 2 spaces, 4 spaces or tabs, or Minify to remove all unnecessary whitespace.
- Fix any errorsIf the JSON is invalid, the line and column of the problem are shown and the cursor jumps to that spot in the input.
- Copy the resultwith one click and paste it back into your editor, API client or documentation.
At a glance
- Actions
- Format, minify and validate
- Indentation
- 2 spaces, 4 spaces or tabs
- Errors
- Message with line and column, cursor moved to the spot
- Large input
- Handles multi-megabyte responses
- Privacy
- Parsed in your browser; never uploaded
- Cost
- Free, no sign-up
Learn more
What JSON is, in one paragraph
JSON (JavaScript Object Notation) is a plain-text format for structured data, defined in RFC 8259. It has only six kinds of value: objects in curly braces with "key": value pairs, arrays in square brackets, strings in double quotes, numbers, true/false, and null. Almost every web API, many configuration files and most log pipelines use it, because it is easy for programs to parse and still readable by people, once it is formatted.
The errors you'll see most often
The validator reports the first problem it finds, with its line and column. These five cause the vast majority of invalid JSON:
| Error | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} |
Delete the comma after the last item |
| Single quotes | {'a': 'b'} |
Use double quotes: {"a": "b"} |
| Unquoted key | {a: 1} |
Quote the key: {"a": 1} |
| Comment | {"a": 1 // note} |
Remove comments; JSON has none |
| Missing comma | {"a": 1 "b": 2} |
Add a comma between items |
When the error position seems wrong, look just before it. A missing closing quote or bracket is often only detected a few characters, or several lines, later, when the parser finds something it didn’t expect. Our guide to fixing invalid JSON errors walks through each message and how to track down the real cause.
Formatting for reading, minifying for sending
Formatted JSON is for people: code reviews, documentation, debugging an API response, or comparing two versions of a config file. Minified JSON is for machines: it is what you store in a database column or send over the network, where every byte counts. Pretty-printed JSON typically shrinks by 10 to 30 percent when minified, before any compression is applied. Because both forms hold identical data, you can switch back and forth freely.
Tips for working with API responses
If you copy JSON out of a browser’s developer tools or a terminal, check the start and end of your paste: stray characters such as a log prefix or a trailing semicolon make the whole document invalid. If the response is a JSON string that itself contains escaped JSON (you’ll see lots of \"), format it once, copy the inner string value without its outer quotes, replace the escaped quotes, and format it again. And before sharing formatted output in a ticket or chat, look for access tokens and personal data; formatting makes them much easier to spot, and to remove.
Questions
Is my JSON sent to a server?
No. Parsing and formatting use your browser's built-in JSON engine, so the data never leaves your device. That matters for API responses and config files that often contain tokens, customer data or internal URLs.
Why does it say my JSON is invalid when it works in JavaScript?
JavaScript object syntax is more relaxed than JSON. JSON requires double quotes around every key and string, doesn't allow trailing commas, comments, single quotes, undefined, NaN or Infinity. The error message points to the first place your text breaks one of those rules.
How large a file can it handle?
Several megabytes is fine on a typical laptop; a 5 MB file formats in well under a second. Very large files of 50 MB or more may make the browser tab slow because the formatted text has to be displayed. For those, a command-line tool such as jq is a better fit.
What is the difference between formatting and minifying?
Formatting adds line breaks and indentation so people can read the structure. Minifying removes every space and line break that isn't inside a string, which makes the data smaller to send or store. Both describe exactly the same data.
Does formatting change my data?
No values change, but two details can. Duplicate keys keep only the last value, as they do in every JSON parser, and numbers are written in their shortest form, so 1.0 becomes 1. Very large integers beyond 9,007,199,254,740,991 can lose precision, as they do in JavaScript generally.
Which indentation should I use?
Two spaces is the most common choice for JSON in web projects and keeps deeply nested data readable. Four spaces is common in Python projects. Tabs let each reader choose their own width in their editor.