JSON Formatter & Validator

Paste JSON, then beautify, minify or validate. Your data never leaves this page.

How to format JSON

  1. Paste your JSON into the box.
  2. Click Beautify to add indentation, or Minify to remove all spaces.
  3. If the JSON is invalid, the message shows the position of the first error.

Common JSON mistakes

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

  1. Paste your text into the box. It can be a short config snippet or a long API response on a single line.
  2. Choose the indent: 2 spaces, 4 spaces or a tab.
  3. 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.
  4. 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:

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

Typical uses

Limits

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.