JSON Formatter & Beautifier: Format, Minify & Inspect JSON Online

Format, validate, repair, and minify JSON data directly in your browser. Supports 2/3/4 spaces, tabs, key sorting, tree views, and automatic syntax repair for trailing commas.

Indent:
Drop file here or click to upload (up to 5 MB)

JSON Structure Metrics

File Size
0.22 KB
222 bytes
Total Keys
8
Object keys count
Max Depth
3
Nesting levels
Objects
2
Dictionaries {}
Arrays
1
Lists []
Primitives
10
Strings, numbers, bools

How to Use JSON Formatter & Beautifier

  1. Paste your raw, minified, or unformatted JSON directly into the editor.
  2. Choose your preferred indentation: 2 spaces (web standard), 3 spaces, 4 spaces, or tabs.
  3. Click "Format (Ctrl+Shift+F)" to beautify the document with readable indentation.
  4. Optionally enable key sorting to normalize object properties alphabetically.
  5. Switch to the "Tree View" tab to visually expand and collapse nested object hierarchies.

Practical Examples

Formatting and Key Sorting

Sorts keys alphabetically and applies 2-space indentation.

Input:
{"z": 1, "a": 2}
Output:
{
  "a": 2,
  "z": 1
}

Auto-Repairing Broken JSON

Fixes trailing commas and unquoted object keys.

Input:
{ name: "test", }
Output:
{
  "name": "test"
}

Common Mistakes & Troubleshooting

  • Formatting minified JSON without checking validity: FormatFlow checks syntax before formatting to prevent corrupting data.
  • Confusing minification with compression: Minifying removes whitespace but does not gzip; combine with HTTP compression for network payloads.
  • Losing key order: Standard JSON objects are unordered; if order matters, avoid sorting keys.

Frequently Asked Questions

How do you format JSON in the browser?

Paste your raw JSON into FormatFlow and press Ctrl + Shift + F (or Command + Shift + F on macOS). You can select 2 spaces, 4 spaces, or tabs for clean indentation.

What is the difference between JSON formatting and validation?

Validation tests whether a string conforms to the strict syntax rules of RFC 8259. Formatting takes valid JSON data and introduces consistent indentation, line breaks, and spacing for human readability.

Does formatting JSON alter key-value data?

No. Formatting only adjusts whitespace outside of quotation marks. All key names, string values, numbers, booleans, and null values remain identical.

Can this tool fix broken or malformed JSON?

Yes! Clicking "Repair JSON" automatically strips trailing commas, converts single quotes to double quotes, quotes bare keys, and removes JavaScript comments.