JSON Formatter, Beautifier & Tree Inspector

Pretty-print JSON with configurable indentation, minify to a single compact line, or explore nested payloads in an interactive tree with 1-click JSONPath copying.

Private by architecture: All processing is 100% client-side memory. Your data never leaves this browser tab.
JSON input
0 lines · 0 charsJSON
Formatted output
Ctrl/Cmd+Shift+C
0 charsJSON

About This Tool

JSON produced by a minifier, a structured logging pipeline, or a compact REST API response is valid RFC 8259 syntax but difficult to read on a single line. This formatter parses and re-serializes payloads through the browser's native JSON.parse and JSON.stringify engine, preserving every value while formatting indentation or minifying whitespace.

When inspecting deeply nested responses, switch to Tree View to collapse branches and copy exact JSONPath selectors in one click. If the input has syntax errors, trailing commas, or single quotes, click Auto-Repair or open JSON Repair, and read our deep dive on JSON Formatting & RFC 8259 Edge Cases.

Key Features

  • Configurable indent: 2, 3, or 4 spaces, or minify to a single compact line.
  • Interactive Tree View & JSONPath: expand or collapse nested nodes and click any path badge to copy its JSONPath.
  • Deep key sorting: optional recursive alphabetical sorting at every object depth for deterministic diffs.
  • Auto-Repair shortcut: fixes broken syntax, trailing commas, and single quotes inline without leaving the page.
  • File upload & drag-and-drop: load a .json file directly from disk into browser memory.
  • Private share links: compress the input into a #z= URL hash fragment so payloads never touch a server.

RFC 8259 JSON Syntax & Common Parse Errors

Standard JSON.parse enforces strict RFC 8259 grammar. The table below lists the most frequent syntax errors in API and LLM payloads and how to resolve them:

Error / Pattern Invalid Input Valid RFC 8259 JSON Auto-Repair Support
Trailing Comma {"a": 1,} {"a": 1} Removed automatically
Single Quotes {'key': 'val'} {"key": "val"} Converted to double quotes
Unquoted Keys {id: 42} {"id": 42} Wrapped in double quotes
JS Literals (NaN, undefined) {"score": NaN} {"score": null} Normalized to null
Inline Comments {/* note */ "ok": true} {"ok": true} Stripped before parsing

Example

Compact input:

{"name":"Alex","active":true,"tags":["json","api"]}

Pretty-printed with 2-space indent:

{
  "name": "Alex",
  "active": true,
  "tags": [
    "json",
    "api"
  ]
}

FAQ

Does formatting change my JSON data or types?
No. Values are preserved through native JSON.parse and JSON.stringify. Only whitespace and, when enabled, alphabetical object key order change.
What does "Sort keys" do?
Recursively sorts object keys alphabetically at every nesting depth while preserving array element order. This makes git diffs and payload comparisons deterministic.
How does Tree View with JSONPath copy work?
Switch the output pane to Tree View to inspect nested objects and arrays interactively. Click any node path badge (such as $.tags[0]) to copy its exact JSONPath expression to your clipboard.
Can this formatter fix trailing commas, single quotes, or malformed LLM JSON?
Yes. Click Auto-Repair in the input toolbar to strip trailing commas, convert single-quoted keys and strings to valid double quotes, and close truncated brackets before formatting.
Does JSON.parse detect duplicate keys?
Per RFC 8259 and ECMA-262, JSON.parse silently retains the last value when an object contains duplicate keys. Use JSON Validator or JSON Schema Validator when strict schema enforcement is required.
Is my JSON uploaded to a server when formatting or sharing?
Never. Parsing, formatting, tree rendering, and #z= URL hash compression execute 100% locally in your browser memory with zero network egress.