JSON Formatter Online: Pretty-Print with Indent, Highlight, and Fold

2026-07-19

Why format JSON

API responses, logs, and config often arrive as one long line. Pretty-printing makes object nesting and array items readable for debugging and code review.

ComTools JSON Formatter (Tools/Json/Formatter) parses and beautifies JSON locally in the browser—nothing is uploaded.

Features

Feature Details
Indent 2 spaces, 4 spaces, or Tab
Syntax highlight Keys, strings, numbers, booleans/null
Line numbers & fold Collapse { / [ blocks for large objects
File upload Load a local .json text file
Errors Shows parse error messages for invalid JSON

Steps

  1. Open JSON Formatter.
  2. Paste JSON, upload a file, or click Sample.
  3. Pick an indent (default 2 spaces).
  4. Click Run / Format.
  5. Copy the pretty result from the editor.

Example

Minified input:

{"name":"ComTools","free":true,"tools":["json","excel"]}

2-space output:

{
  "name": "ComTools",
  "free": true,
  "tools": [
    "json",
    "excel"
  ]
}

Common scenarios

Scenario Approach
Inspect API responses Paste from DevTools / Postman
Readable configs Upload .json → format → copy back
One-line output Use JSON Minify
Validity only JSON Validator
From Excel Excel to JSON then format

Formatter vs validator vs minify

Need Tool
Pretty indent & fold JSON Formatter
Valid or not JSON Validator
Smallest payload JSON Minify
Diff two docs JSON Compare

Formatting runs JSON.parse first; failures mean you must fix syntax before beautifying.

Notes

  • Standard JSON only (double-quoted keys)—trailing commas and single quotes fail.
  • Very large files are better in a desktop editor; browsers have memory limits.
  • Local processing suits sensitive payloads—avoid untrusted machines.

FAQ

Key order changed?
Engines usually preserve insertion order; do not rely on key order in protocols.

Sort keys alphabetically?
Not currently—stringify keeps parse order.

vs VS Code Format?
Instant web use with fold/highlight for quick paste debugging.


中文版