🔧

JSON Formatter & Validator

Paste JSON to format, validate, or minify it instantly. All processing happens in your browser — no data is ever uploaded.

Indent:
1
Formatted output will appear here…

Why Use a JSON Formatter?

Raw JSON is often minified or inconsistently indented, making it hard to read. This tool instantly formats JSON into a clean, human-readable structure — and catches syntax errors with precise messages so you can fix them fast.

Features

  • Format JSON with 2 or 4-space indentation
  • Minify JSON to the smallest possible size
  • Validate JSON and see detailed error messages
  • Sort object keys alphabetically
  • Load a .json file directly from your device
  • One-click copy of the formatted output
  • 100% browser-based — no data ever leaves your device

Smart Auto-Fix: Repairable JSON Errors

Click the Auto Fix button to instantly repair common JSON mistakes. The fixer runs multiple passes until the JSON is valid:

  • Trailing commas before } or ] — e.g. {"a":1,} → {"a":1}
  • Single-quoted strings — e.g. 'hello' → "hello"
  • Unquoted object keys — e.g. {name: "Alice"} → {"name": "Alice"}
  • Missing commas between adjacent properties or array items
  • Missing closing } or ]
  • Mismatched or curly/smart quotes
  • undefined, NaN, Infinity → replaced with null
  • Unterminated string values (missing closing quote)
  • JS-style comments (// and /* ... */)
  • Control characters inside strings (tab, newline, etc.)
  • Unescaped double quotes inside a string value — e.g. "Markdown"tool" → auto-escaped
  • Wrong closing bracket order — e.g. ["a","b"} → ["a","b"]
  • Number value with invalid suffix — e.g. "rate":33% → "rate":"33%"

When Auto-Fix Cannot Help

Some errors require manual correction. The button shows the specific reason:

  • Number starting with a dot — .1 (write 0.1 instead)
  • Number with a leading zero — 0123 (write 123 instead)
  • Number with multiple decimal points — 123.45.67
  • Invalid escape sequence — \z (valid: \n \t \r \" \\ \/ \b \f \uXXXX)
  • Incomplete Unicode escape — \u123 (must be exactly 4 hex digits, e.g. \u0041)

Example

Input — minified JSON:

{"name":"Alice","age":30,"skills":["Go","TypeScript"]}

Output — formatted with 2-space indent:

{
  "name": "Alice",
  "age": 30,
  "skills": [
    "Go",
    "TypeScript"
  ]
}

Related Tools