JSON Formatter & Validator

Use this JSON Formatter & Validator to pretty-print JSON, minify it for APIs, and detect invalid JSON errors instantly. JSON is the most common data format for APIs, configuration files, logs, and web apps, but it’s easy to break with a single missing quote, extra comma, or unmatched bracket.

Paste your JSON into the editor and choose Format to add indentation and make nested objects readable, Minify to remove whitespace for faster transfer, or Validate to confirm it follows strict JSON rules. If validation fails, the most common causes are trailing commas, single quotes instead of double quotes, missing quotes around property names, or unescaped characters inside strings.

JSON Tools

1

How to format, validate, and minify JSON

  1. Paste JSON into the JSON Input editor.
  2. Click Format JSON for readable output.
  3. Click Validate JSON to check for errors.
  4. Click Minify JSON to reduce size for APIs and storage.
  5. Copy or download the result.

Tip: if validation fails, remove trailing commas and use double quotes only.

Common JSON errors and fixes

ErrorCauseFix
Unexpected tokenExtra characters or broken syntaxRemove extra text before { or [ and check missing quotes/commas
Trailing commaComma after the last itemDelete the final comma
Single quotesJSON requires double quotesReplace ' with "
Missing quotes on keys{a:1} is invalid JSONUse {"a":1}
Unescaped quotesQuotes inside strings need escapingEscape as \\"

JSON examples

Object

{"name":"NetworkWhois","tools":["whois","dns","json"]}

Array

[1,2,3,4]

Nested

{"user":{"id":1,"roles":["admin","editor"]}}

Best practices

  • Validate JSON before using it in production APIs.
  • Keep formatted JSON for debugging, minified JSON for transport.
  • Don’t confuse JSON with JavaScript objects — JSON is stricter.
  • If you copy between systems, watch for hidden newlines and encoding differences.

Frequently asked questions

Why does JSON require double quotes?

Strict JSON requires double quotes for strings and property names. Single quotes are valid in JavaScript, but not valid JSON.

What is the difference between JSON and JavaScript objects?

JSON is a data format with strict rules (double quotes, no comments, no trailing commas). JavaScript objects are more flexible and allow extra syntax.

How do I fix “Unexpected token” errors?

Unexpected token errors usually mean invalid characters, a missing quote, a missing comma, or a trailing comma. Check the highlighted line/column and remove extra text before the first { or [.

What is a trailing comma and why is it invalid?

A trailing comma is a comma after the last item in an object/array. JSON does not allow it, so validators will fail.

Can JSON contain comments?

Strict JSON cannot contain comments. Some tools accept JSONC (JSON with comments). This formatter can strip comments when you enable “Allow comments (JSONC)”.

What should I do if the validator shows a line number error?

Go to the highlighted line, check nearby commas/quotes/brackets, and ensure keys are quoted and commas only appear between items.

Why does my JSON validate in one tool but fail in another?

Different tools accept different extensions (comments, trailing commas). Make sure you are using strict JSON if you’re sending data to an API.

Is minified JSON still valid?

Yes. Minifying only removes whitespace. The structure and data are unchanged, so it remains valid JSON.

How do I escape quotes and newlines in JSON strings?

Escape quotes as \" and newlines as \n. Backslashes must be escaped too (\\).

What are JSON objects vs arrays?

Objects use { } and store key-value pairs. Arrays use [ ] and store ordered values.

Related tools