Tools / Backend & API / JSON Formatter

JSON Formatter & Validator

Paste your JSON to format, minify, validate, compare, or query instantly. Auto-formats on paste.

Input JSON

1

Output

How to fix invalid JSON — common errors and automatic repair

JSON is strict. A single misplaced comma or unquoted key breaks the whole document. Common errors our formatter catches and auto-repairs:

  • Trailing commas — valid in JavaScript objects, invalid in JSON. {"a":1,} fails.
  • Single quotes — JSON requires double quotes. {'a':1} fails.
  • Unquoted keys — all keys must be strings with double quotes. {a:1} fails.
  • JavaScript comments// comment and /* block */ are not valid JSON.
  • Undefined / NaN / Infinity — these are JavaScript values, not JSON. Use null or omit.
  • Hex / octal / binary numbers — only decimal numbers allowed.
  • Unescaped control characters — newlines, tabs, etc. inside string values must be escaped with \n, \t.

Click "Fix & Format" to apply all of these in one pass. Underlying this is JSON5-style parsing that's lenient on input and strict on output.

JSON vs JSON5 vs JSONC vs NDJSON — which should you use?

The JSON family has spawned several dialects. Short guide:

FormatAllowsUse for
JSON (RFC 8259)strict onlyAPI payloads, data storage, wire format
JSON5comments, trailing commas, unquoted keys, single quotes, hex numbersHuman-edited config files
JSONC (JSON with Comments)line + block comments, trailing commastsconfig.json, devcontainer.json — VS Code ecosystem
NDJSON / JSON Linesone valid JSON object per line, newline-delimitedStreaming data, log files, ML training data
HJSONcomments, unquoted strings, Ruby-like syntaxRarely seen; JSON5 won

For APIs: always produce strict JSON. For config you write by hand: JSONC or JSON5. For logs / event streams: NDJSON (one complete JSON per line means you can grep and split without a full-file parse).

Minify vs beautify — when to use each

Beautify (also called "pretty-print" or "format"): adds indentation and line breaks. Makes JSON readable for humans. Increases file size by 30-60%.

Minify: removes all whitespace. Smaller file, faster to transmit, harder to read. Useful for production API responses, payload size optimization, embedding JSON in source code.

# Beautified (readable)
{
  "user": "alice",
  "email": "alice@example.com",
  "roles": [
    "admin",
    "editor"
  ]
}

# Minified (compact)
{"user":"alice","email":"alice@example.com","roles":["admin","editor"]}

Typical production pattern: minify for HTTP responses, beautify before storing in git. Our formatter toggles between the two in one click and preserves the underlying data exactly — no key order changes, no type coercion.

Frequently Asked Questions

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format that's easy for humans to read and write, and easy for machines to parse and generate.

How do I fix invalid JSON?

Common issues include trailing commas, single quotes instead of double quotes, unquoted property names, and JavaScript comments. Our Fix & Format feature automatically repairs these.

What's the difference between minify and beautify?

Beautify adds indentation and line breaks for readability. Minify removes all whitespace to reduce file size, useful for production deployments.

Copyright © 2026 BuildStudio. All rights reserved.

Designed and Developed by Webority Technologies

Copied to clipboard