JSON Formatter and Validator
FV-01Paste JSON to format it with 2 spaces, 4 spaces or tabs, shrink it to one line, or check it. If it is not valid, you get the line and column of the first error.
Runs in your browser. Nothing is uploaded.
JSON
Result
How to use it
- Paste your JSON into the input box, or open a .json file (up to 5 MB) or drop it on the box.
- Choose Format, Minify or Validate. The result updates as you type.
- Pick 2 spaces, 4 spaces or Tab. Turn on Sort keys if you want object keys in order.
- Copy the result or download it as a .json file.
- Use Share link to copy a link that holds your input after the # in the address.
What Format, Minify and Validate do
Format re-indents the JSON so each key and array item sits on its own line, using 2 spaces, 4 spaces or a tab. Minify removes all the whitespace and gives you one line. Validate checks the text and replies with Valid JSON and what it found, such as an object with 5 keys or an array with 3 items. Sort keys orders the keys of every object by character code, so capital letters come before lowercase. It never reorders items inside arrays.
Big numbers and exact values stay as written
Many tools parse JSON into the language's own numbers and write it back, which rounds long integers. This one keeps every number and string exactly as you typed it. A 20 digit ID such as 12345678901234567890 comes out the same, and so does 1.50 instead of 1.5. Only the whitespace around values changes. That makes it safe for IDs, order numbers and timestamps that you plan to paste back into a request.
Fixing invalid JSON
The formatter follows the JSON standard, so it rejects single quotes, comments, trailing commas and values such as NaN or undefined. The error names the problem and the line and column where parsing stopped. Press Go to error to select that character in the input. The position is where the parser gave up, which can be just after the real mistake: a missing comma is reported at the start of the next key. Fix the first error, then check again, because later ones only show up once the first is gone.
Your JSON stays in your browser
Formatting, minifying and validating all run in your browser, so API responses and config files are not uploaded and there is nothing to sign up for. Share builds a link with your input and settings stored after the # in the address. Browsers do not send that part to a server. Input that is too long for a link shows a message, and Download works instead.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Unexpected character "'" | A character that cannot start a value. Single quotes, // comments, NaN, undefined and a trailing comma before ] all land here, each showing its own character. | Use double quotes, remove comments, and delete the comma before the closing bracket. |
Expected a string key | An object key is not in double quotes, or there is a comma right before the closing }. | Wrap the key in double quotes, or remove the trailing comma before a closing brace. |
Expected ',' or '}' | Two items in an object have no comma between them. Inside an array the message says ']' instead of '}'. | Add the missing comma where the position points, or just before it. |
Unexpected end of input | The text stops where a value is still expected, usually because the end of the JSON was cut off. If the cut comes after a complete value, such as {"a":1, the message instead says it expected a comma or a closing brace. | Add the missing value and the closing } or ]. |
Invalid string (unescaped control character or bad escape) | A string contains a raw line break or tab, or a backslash that is not a valid escape. | Write line breaks as \n and tabs as \t, and double any literal backslash. |
Unexpected data after the end of the JSON value | There is more text after the first complete JSON value, for example two objects pasted one after the other. | Wrap the values in one array separated by commas, or format them one at a time. |
Questions people ask
How do I format JSON online?
Paste your JSON into the input box and choose Format. The result appears as you type, indented with 2 spaces, 4 spaces or a tab, as you choose. Then copy it or download it as a .json file. Nothing is uploaded; it all runs in your browser.
How do I validate JSON?
Click Validate. A valid document returns Valid JSON and what it holds, for example an object with 5 keys. An invalid one returns the error message with the line and column where parsing stopped, and a Go to error button that selects that spot in your text.
How do I minify JSON?
Click Minify. All spaces and line breaks outside strings are removed and the JSON comes out on one line. Keys, values and numbers are unchanged. Sort keys also applies to minified output if you turn it on.
Why does my JSON say unexpected character?
The parser met a character that cannot start a JSON value. Common causes are single quotes instead of double quotes, comments, NaN or undefined, and a trailing comma before a closing square bracket. The error shows the character and its line and column.
Does the JSON formatter round big numbers?
No. Numbers and strings are kept exactly as written, so an ID like 12345678901234567890 is not rounded. Only whitespace is added or removed. This matters when you format an API response that contains long numeric IDs.
Is my JSON uploaded when I format it?
No. Formatting, minifying and validating run in your browser, and nothing you paste is sent to a server. The Share link keeps your input after the # in the address, and browsers never send that part to a server.
About this tool
Paste JSON to format it, shrink it, or find the exact line and column of a syntax error. Numbers are kept exactly as you wrote them, so large IDs are not rounded.