WebzTools
Menu

JSON Formatter

JSON that arrives from an API or a config file is usually minified onto one line, which is unreadable the moment it grows past a few fields. Beautifying it with proper indentation makes the structure obvious, and the same tool works in reverse to minify readable JSON for transport.

A third button, Validate Only, checks that your document parses without changing anything in the output box, which is useful when you just want a yes-or-no answer. If the document will not parse, you get the parser's error instead of a blank result.

Runs in your browser. JSON Formatter processes your input on your own device. Nothing you enter or upload is sent to a server.

Did this tool help you? ☕

WebzTools is free to use. If this tool saved you some time, you can support the project with a coffee and help us keep improving the tools.

Buy Me a Coffee (opens in a new tab)

How to use the JSON Formatter

  1. Paste your JSON into the input area.
  2. Pick an indentation of 2 spaces, 4 spaces or a tab.
  3. Select Beautify, Minify or Validate Only.
  4. If it fails to parse, read the error and fix the position it points to.
  5. Copy the output.

Beautify, minify and Validate Only

All three actions parse your input with the same strict JSON parser, so anything that passes Beautify or Minify would also pass Validate Only, and vice versa.

Beautify with 2-space indentation

Input

{"name":"Ada","skills":["JSON","JS"]}

Output

{
  "name": "Ada",
  "skills": [
    "JSON",
    "JS"
  ]
}
ActionWhat happens to the output box
BeautifyReplaced with the parsed document, indented at 2 spaces, 4 spaces or a tab.
MinifyReplaced with the parsed document on a single line, with no spaces between tokens.
Validate OnlyLeft unchanged. Only the message above it updates, to valid or invalid.

JSON is stricter than a JavaScript object

Code you could paste straight into a .js file is not automatically valid JSON. JSON requires double-quoted keys and string values, forbids a comma after the last item in an object or array, and has no syntax for comments at all.

Common reasons JSON.parse rejects a document
Looks fine in JavaScriptNot valid JSON because
{ name: "Ada" }the key is not wrapped in double quotes
{ 'name': 'Ada' }single quotes are used instead of double quotes
{ "skills": ["JS", "JSON",] }there is a comma after the last array item
{ "name": "Ada" } // a commentJSON has no comment syntax, // or /* */

Things worth knowing

  • This checks JSON syntax only, not a schema: it cannot tell you whether the fields, types or structure match what your application expects.
  • There is no interactive, collapsible tree view. The formatted result is plain indented text in the output box.

Frequently asked questions

Why is my JSON invalid?

The usual culprits are trailing commas after the last item, single quotes instead of double quotes, unquoted keys, and comments. All four are legal in a JavaScript object literal but not in JSON: JSON is a stricter, language-independent data format, and a JavaScript object is not automatically valid JSON just because it looks similar.

Does this check my JSON against a schema?

No. It checks that the text is syntactically valid JSON, the same check JSON.parse performs. It does not know what shape your data is supposed to have, so a document with the wrong fields or types, but correct JSON syntax, is reported as valid.

Is my data sent anywhere?

No. Parsing and formatting run in your browser, which matters when the payload contains tokens or customer data.

Does minifying change the data?

No. It removes only whitespace between tokens. The parsed value is identical; it is simply smaller to transmit.

What does Validate Only do differently from Beautify?

Beautify and Minify both replace the output box with a reformatted copy. Validate Only leaves the output box as it is and only reports, above it, whether the input parses.

Browse all developer tools