Home/Dev Tools/JSON Formatter

JSON Formatter

Beautify

Beautify and format JSON with indent control, key sorting and null removal.

Original
Formatted
Indent
Keys
Input
Mode
Input
Loading editor…
Output
Loading editor…
✨ AI Code Explanation
Mode

What Is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging structured data. It organises data as name/value pairs grouped in objects {} or ordered lists []. Values can be strings, numbers, booleans (true / false), null, nested objects, or arrays. JSON files use the .json file extension and are served over HTTP with the MIME type application/json. Because it is language-independent and human-readable, JSON is the standard data format for REST APIs, config files, and web applications.

JSON Formatter & Beautifier — Online Tool

A JSON formatter (also called a JSON beautifier or JSON pretty-printer) takes compact or unreadable JSON and reformats it with consistent indentation and line breaks, making it easy to read, debug, and share. Formatting and beautifying JSON are the same operation — both produce pretty-printed output from a single line of minified JSON.

How to Format / Beautify JSON

  • Paste your JSON into the Input pane, or click Upload to load a .json file.
  • Optionally paste a public JSON URL into the Fetch from URL bar and click Fetch.
  • Choose your indent style — 2 spaces, 4 spaces, or Tab.
  • Click Beautify to pretty-print the JSON in the output pane.
  • Toggle Sort keys to alphabetise every object key recursively.
  • Toggle No nulls to strip all null-value properties from the output.
  • Enable JSONC mode to strip // and /* */ comments before formatting.
  • Enable Repair to auto-remove trailing commas and strip the UTF-8 BOM.
  • Enable Live mode to auto-format as you type (300 ms debounce).
  • Click Download to save the formatted JSON as formatted.json.

Proper JSON Format — Rules Cheat Sheet

  • Double quotes only — Keys and string values must use "double quotes". Single quotes are not valid JSON.
  • No trailing commas{ "a": 1, } is invalid. Use Repair mode to auto-fix trailing commas.
  • No comments — Standard JSON does not allow // or /* */ comments. Use JSONC mode to strip them before formatting.
  • Quoted keys{ name: "Alice" } is invalid. Object keys must always be double-quoted: { "name": "Alice" }.
  • Boolean & null literals — Use lowercase true, false, and null. Python-style True, False, and None are not valid JSON.
  • No undefinedundefined is a JavaScript value. Use null in JSON instead.
  • Numbers — No leading zeros (007 is invalid), no trailing decimal points (1.), and no NaN or Infinity.
  • File extension — JSON files use .json.
  • MIME type — Serve JSON responses with Content-Type: application/json.

Format vs Beautify vs Pretty-Print — Are They the Same?

Yes — "JSON format", "JSON beautify", and "JSON pretty-print" all mean the same thing: taking minified or unreadable JSON and adding whitespace, newlines, and indentation to make it human-readable. This tool does all three.

Common JSON Errors — How to Fix Them

  • Trailing comma{ "a": 1, } is invalid JSON. Enable Repair to auto-fix, or remove the comma manually.
  • Single quotes — JSON requires double quotes. Change 'value' to "value" throughout.
  • Unquoted keys{ name: "Alice" } is invalid. Keys must be double-quoted: { "name": "Alice" }.
  • Comments — Standard JSON has no comments. Enable JSONC mode to strip // and /* */ comments first.
  • Unexpected token — Usually a missing comma, unclosed bracket, or stray character. The error message shows the line and column number.
  • Windows line endings — Files with \r\n line endings parse correctly, but if you see odd characters enable Repair to strip the UTF-8 BOM.

Tips & Tricks

  • JSONC (JSON with Comments) — VS Code settings, TypeScript config (tsconfig.json), and many tool configs use JSONC — JSON that allows // comments. Enable the JSONC toggle to strip comments before formatting without editing the file.
  • Sort Keys — Enable Sort keys to alphabetise every object key recursively. Useful when comparing two JSON objects by eye or producing deterministic output for diff tools.
  • Remove Nulls — Enable No nulls to strip all properties whose value is null from the output, including deep inside nested objects and arrays. Useful for cleaning API responses.
  • Repair Mode — Automatically removes trailing commas and the UTF-8 BOM character — the two most common issues in hand-edited or copy-pasted JSON.
  • URL param — Append ?json={"key":"value"} to the page URL to pre-fill the editor. Useful for sharing a specific JSON snippet with a team member.
  • Big Int — Enable Big Int mode when formatting JSON that contains 64-bit integers (common in database exports and financial APIs). Standard JSON.parse() silently loses precision on numbers larger than 2⁵³−1.

Related Tools

  • JSON Minifier — strip whitespace and compress JSON for production
  • JSON Validator — check JSON syntax and get a structural summary
  • JSON Viewer — explore JSON as an interactive collapsible tree
  • JSON Diff — compare two JSON objects side-by-side

Is My JSON Sent to a Server?

No. All formatting runs entirely in your browser using JavaScript. Your JSON data never leaves your machine — not even the AI Explain feature sends your code to our servers unless you explicitly click Explain with AI.