JSON Formatter
Format, minify and validate JSON live — with lenient repair (comments, trailing commas, single quotes), tab indent, precise code-frame errors and a structure summary.
About this ToolHow it works, benefits & use casesTap to collapse
This JSON formatter beautifies, minifies and validates JSON the moment you paste it. Switch between Beautify and Minify with a single toggle: beautify re-indents with 2, 4 or 8 spaces or tabs and can sort object keys alphabetically, while minify strips every byte of optional whitespace. A lenient repair mode lets you feed in near-JSON — single quotes, unquoted keys, trailing commas and // or /* */ comments are normalised before formatting, and a banner tells you when a repair happened. When the input is genuinely invalid, you get a precise code-frame error with the line, column and a caret-marked snippet pointing at the problem. Each successful format produces a structure summary — root type, total keys, maximum nesting depth, and counts of objects, arrays, strings, numbers, booleans and nulls, plus the input byte size. Presets and a local history menu remember your settings and recent inputs, all in the browser.
How to Use
- 1Choose Beautify or Minify with the mode toggle at the top.
- 2In Beautify mode, pick your indentation (2, 4 or 8 spaces or tab) and optionally turn on "Sort keys alphabetically".
- 3Enable "Repair (lenient)" if your input has comments, trailing commas, single quotes or unquoted keys.
- 4Paste your JSON into the input panel — it formats live — or click "Load example" (the example matches your repair setting).
- 5Press "Format JSON" or "Minify JSON" to validate, then copy, download, or share the result.
- 6Read the JSON summary below the output, and recall earlier inputs from the history menu or save option sets as presets.
Key Benefits
- Beautify and minify from one tool with an instant mode toggle
- Lenient repair accepts comments, trailing commas, single quotes and unquoted keys
- Precise code-frame errors with line, column and a caret-marked snippet
- Optional alphabetical key sorting and 2/4/8-space or tab indentation
- Structure summary: root type, key count, max depth, and per-type element counts
- Local history of recent inputs and savable option presets
- Live formatting plus copy, download and shareable URLs — entirely in-browser
Common Use Cases
- Cleaning up an unreadable single-line API response into indented JSON
- Repairing hand-written config or JSON5-style snippets into strict JSON
- Pinpointing a syntax error in a large payload using the line/column code frame
- Normalising key order with alphabetical sorting before diffing two files
- Inspecting the shape of an unfamiliar payload via the structure summary
Options
Accept comments, trailing commas, single quotes, unquoted keys
0 characters · live
Paste JSON above to format it live.
Quick Reference: JSON Formatting Tips
Standard Format
Use 2-space indentation for readability
Validate First
Always validate JSON before formatting
Sort Keys
Enable key sorting for consistent output
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related guides
- Guide · 12 min readJSON to TypeScript: The Complete Guide (with examples)Auto-generate TypeScript types from JSON, then refine them. Real-world traps with optional fields, discriminated unions, snake_case mapping, and runtime validation with Zod.Read the guide
- Announcement · 18 min readWelcome to consolelog.tools: 300+ Free Developer Tools, Zero InstallationThe story behind building consolelog.tools - a comprehensive platform with 300+ free developer utilities. Learn about our mission, technology stack, and vision for the future of developer productivity.Read the guide
Related tools
- JSON Path FinderFind and test JSON paths
- API Response FormatterFormat and beautify API responses
- HTTP Header ParserParse and analyze HTTP headers
- OpenAPI Spec ViewerView and explore OpenAPI/Swagger specifications
- Package.json Scripts GeneratorGenerate common npm scripts for different project types and workflows
- User Agent ParserParse and analyze user agent strings
With "Repair (lenient)" enabled, the formatter accepts input that strict JSON.parse would reject: line and block comments, trailing commas, single-quoted strings and unquoted object keys. The input is normalised into valid JSON before formatting, and a green banner appears confirming that a repair was applied.
In Beautify mode you can indent with 2, 4 or 8 spaces, or with a tab character. Minify mode ignores indentation entirely and removes all optional whitespace to produce the smallest valid JSON.

