⚒ToolHub

JSON Formatter & Validator

Format, beautify, minify and validate JSON instantly. Shows the exact line of syntax errors. Free and private — runs in your browser.

How to format JSON

  1. Paste your JSON into the input box. It can be a single line copied from an API response or a whole file.
  2. Choose the indentation: 2 spaces, 4 spaces or tabs.
  3. Click Format to beautify it, or Minify to remove all whitespace.
  4. If the JSON is invalid, a red message shows what is wrong and the line and column where the parser stopped.
  5. Click Copy to put the result on your clipboard.

Everything happens in your browser with the built-in JSON.parse and JSON.stringify functions. Nothing is uploaded, so it is safe to paste configuration files or API responses that contain private data.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. It is used by almost every web API, by configuration files such as package.json, and by many databases. A JSON document is built from six kinds of values:

  • Objects — key/value pairs in curly braces, e.g. {"id": 7}. Keys must be strings in double quotes.
  • Arrays — ordered lists in square brackets, e.g. [1, 2, 3].
  • Strings — text in double quotes. Special characters are escaped with a backslash, such as \n for a new line.
  • Numbers — integers or decimals like 42 or -3.14. No leading zeros, no NaN.
  • Booleans — true or false, in lower case.
  • null — an empty value.

Format vs minify: an example

The sample in the box above is minified. It is 68 characters on one line:

{"name":"ToolHub","tools":["json","words"],"free":true,"users":1200}

After Format with 2 spaces, each key sits on its own line and nested values are indented, so you can scan the structure at a glance. Formatted JSON is easier to read, review in a pull request and debug. Minified JSON is smaller: on large payloads, removing whitespace often cuts the size by 10–20%, which matters when the data is sent over a network many times. The data itself is identical either way.

Common JSON errors and how to fix them

  • Trailing commas — [1, 2,] is valid JavaScript but not valid JSON. Delete the last comma.
  • Single quotes — {'name': 'Ann'} fails. Strings and keys must use double quotes.
  • Unquoted keys — {name: 1} must be written {"name": 1}.
  • Comments — standard JSON does not allow // or /* */. Remove them, or use a format such as JSONC that your tool supports.
  • Unescaped characters — a raw line break or tab inside a string is not allowed; use \n and \t.
  • Wrong literals — True, None and undefined come from other languages. JSON only accepts true, false and null.

Tip: when the error points to a line, look at the character just before it as well. A missing comma or quote on the previous line is often the real cause, because the parser only notices the problem one token later.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting and validation happen entirely in your browser using JavaScript's built-in JSON parser.

What does minify JSON mean?

Minifying removes all unnecessary whitespace and line breaks, making the JSON smaller to send over a network.

Why is my JSON invalid?

Common causes are trailing commas, single quotes instead of double quotes, unquoted keys and comments. The error message shows the line and column of the problem.