Work · 20+

JSON Formatter

Validate, Format, and Explore JSON

Paste JSON to validate instantly. All errors and warnings with exact line numbers, a collapsible tree view, formatted output, and one-click copy or minify.

Back to timeline
300 × 250
Advertisement
Use tool</> EmbedPress ⌘D / Ctrl+D to bookmark

Multi-pass validation

Format & validate JSON

How to Use the JSON Formatter

  1. Paste JSON into the input area. Validation runs instantly as you type.
  2. If errors or warnings are detected, the diagnostic panel lists each one with the line number and a suggestion.
  3. Switch between Tree, Formatted, and Minified tabs to explore the output.
  4. Use Expand All / Collapse All to control the tree depth.
  5. Click Copy to copy the current tab's output to the clipboard.

What Makes JSON Invalid

JSON (RFC 8259) is stricter than most developers expect. Common reasons validation fails:

  • Trailing commas — a comma after the last item in an object or array: {"a": 1,}. Allowed in JSON5, not in JSON.
  • Single-quoted strings{'key': 'value'}. All strings must use double quotes.
  • Unquoted keys{key: "value"}. Property names must be double-quoted strings.
  • Comments — JSON has no comment syntax. Neither // line nor /* block */ comments are valid.
  • Special number valuesNaN, Infinity, and -Infinity are not JSON primitives.
  • Unclosed structures — a missing }, ], or " ends parsing prematurely.

JSON vs JSON5 vs JSONC

Many configuration files look like JSON but are JSON5 or JSONC (JSON with Comments), which relax some restrictions:

FeatureJSONJSON5JSONC
Double-quoted stringsRequired
Single-quoted strings
Trailing commas
// and /* */ comments
Unquoted keys

This formatter validates against strict JSON (RFC 8259) but flags trailing commas and comments as warnings — non-standard patterns that it can identify and describe rather than just rejecting outright.

How the Tree View Works

After valid JSON is parsed, the tree view renders the entire structure as nested collapsible sections. Each object and array can be opened or collapsed independently using the toggle arrow. Leaf values are color-coded by type for quick scanning: strings in green, numbers in blue, booleans in purple, null in gray.

The Expand All and Collapse All buttons open or close every node at once. For large JSON files with many nested arrays or objects, starting collapsed and expanding only the branches you need is more practical than scrolling through a fully expanded tree.

Formatting and Minifying

Formatted JSON uses 2-space indentation by default — the most common convention for web APIs and configuration files. The minified version removes all whitespace not inside string values, producing a single compact line — useful for reducing HTTP payload size or embedding JSON in source code.

A 10 KB formatted JSON file typically minifies to 6–7 KB — a 30–40% reduction. For deeply nested structures with long string values, the savings are proportionally smaller because the values, not the whitespace, dominate the byte count.

FAQ

JSON Formatter Questions

Short answers for readers and answer engines.

{item.question}

{item.answer}

Browse

Explore All Tools