JSON Formatter & Validator
Paste JSON, then beautify, minify or validate. Your data never leaves this page.
How to format JSON
- Paste your JSON into the box.
- Click Beautify to add indentation, or Minify to remove all spaces.
- If the JSON is invalid, the message shows the position of the first error.
Common JSON mistakes
- Trailing commas after the last item:
[1,2,] - Single quotes instead of double quotes:
{'a':1} - Unquoted keys:
{a:1} - Comments, which standard JSON does not allow
FAQ
Is my JSON sent to a server?
No. Parsing and formatting use your browser’s built-in JSON engine. This makes it safe for configs and API responses, though you should still avoid pasting secrets into any website.
How large a file can it handle?
Several megabytes work fine on modern devices. Very large files depend on your browser memory.
Do you need Base64 instead?
See the Base64 encoder and decoder.
Using the formatter
- Paste your text into the box. It can be a short config snippet or a long API response on a single line.
- Choose the indent: 2 spaces, 4 spaces or a tab.
- Press Beautify to spread the data over indented lines, or Minify to squeeze it onto one line with no spaces. A green "Valid JSON" message confirms the text parsed.
- Press "Copy result" to put the contents of the box on your clipboard, or "Clear" to start over.
The tool replaces the text in the box with the formatted version, so what you see is exactly what gets copied. If you want to keep the original, copy it somewhere else first.
How validation and error positions work
The page hands your text to the JavaScript engine's own JSON.parse. If parsing succeeds, the result is written back with JSON.stringify using your chosen indent. If it fails, the message "Invalid JSON:" is shown followed by the browser's own explanation. When the browser reports only a character position, the tool counts the line breaks before that position and adds a line and column, for example "(line 3, column 14)". Some browsers already include line and column in their message, in which case it is shown as is, so wording differs between Chrome, Firefox and Safari.
The error points to where the parser gave up, which is often just after the real mistake. A missing comma between two properties is reported at the start of the second one. An unclosed string can be reported at the very end of the text. Look a little before the position.
Example
Pasting {"id":7,"tags":["a","b"],"ok":true} and pressing Beautify with 2 spaces gives:
{"id": 7,"tags": [followed by"a",and"b"on their own lines and a closing],"ok": true}
Pressing Minify on that result returns the original single line. Because the text is parsed and rewritten, formatting is normalised: extra spaces and line breaks disappear, and numbers are rewritten in their shortest form, so 1.0 becomes 1 and 1e2 becomes 100. Escaped characters such as é come back as the character itself.
Things that behave differently from what you might expect
- Key order is preserved in the sense that properties come back in the order they were written, except that keys that look like whole numbers (such as "2" or "10") are always listed first in ascending order. This is how JavaScript objects work, not a bug.
- Duplicate keys: if the same key appears twice in one object, the last value wins and the earlier one is silently dropped. Beautify will not warn you.
- Big numbers lose precision. JavaScript stores numbers as 64-bit floating point, so integers above 9007199254740991 may be rounded. Long numeric IDs should be kept as strings.
- Empty containers stay compact:
[]and{}are not expanded across lines.
Typical uses
- Reading a minified API response or a log line that contains a JSON payload.
- Checking a hand-edited config file before deploying it, to catch a trailing comma or a missing quote.
- Shrinking a payload before pasting it into a command line or a test fixture.
- Normalising indentation so that two files can be compared line by line in a diff tool.
Limits
- Only strict JSON is accepted. Files with comments, single-quoted strings or unquoted keys (often called JSON5 or JSONC) are reported as invalid, even though many tools tolerate them.
- The tool checks syntax, not meaning. It cannot tell you that a field is missing or has the wrong type; that requires a schema validator.
- Multiple JSON documents pasted one after another, as in newline-delimited logs, are not valid as a whole. Format them one at a time.
- Pressing Beautify on text that has an error leaves your input untouched, so nothing is lost.
More questions
Why does it say my JSON is invalid when my editor accepts it?
Editors and some libraries allow extras such as comments or trailing commas. This page follows the strict rules used by JSON.parse, which is what most programs and servers use when they read your data.
Which indent should I choose?
Two spaces keep deeply nested data narrow; four spaces are easier to scan in shallow data; a tab lets each reader's editor choose the width. Pick whatever matches the project you are pasting into.
Does minifying change the data?
No values change. Only whitespace outside of strings is removed, apart from the number normalisation described above, so the minified text parses to the same data.