GALAXY OF TOOLS

DEV SECTOR

JSON Formatter

Beautify, minify and validate JSON with exact error locations and a collapsible tree view.

Result

“Fix common issues” rewrites single quotes, unquoted keys, trailing commas, comments and Python’s True/False/None into valid JSON. In the tree, click a key to copy its path.

Runs entirely in your browser. Nothing you enter or upload is sent to a server.

A JSON formatter and validator that shows exactly what is wrong

The JSON Formatter turns a dense, single-line API response into neatly indented, readable JSON — and does the reverse when you need the smallest possible payload. Paste JSON, drop a .json file onto the input or load the sample, and you get a beautified or minified copy, a validation report and a collapsible tree you can click through.

When JSON is broken, many validators only say “Unexpected token”. This one names the problem in plain English — a trailing comma, a single-quoted string, an unquoted key, a missing comma — and points to the exact line and column with a caret under the character at fault. It also warns about duplicate keys, which are easy to miss and silently lose data in most parsers.

Everything runs locally in your browser. Your JSON is never uploaded, logged or stored, so it is safe to inspect responses that contain access tokens, customer records or configuration secrets.

How to use the JSON Formatter

  1. Paste JSON into the JSON input box, drag a file onto it or press Load file. A sample is loaded the first time so you can see how it works.
  2. Pick an indent of 2 spaces, 4 spaces or a tab, and tick Sort keys A–Z if you want every object’s keys in alphabetical order.
  3. Press Format to beautify, Minify to strip all whitespace, or Validate to check the JSON without changing the result. With Live update on, the result follows your typing.
  4. If something is wrong, read the line, column and snippet in the red box, then press Go to error to jump to that spot in the input.
  5. Switch the result to Tree to expand and collapse objects and arrays. Click any key to copy its path, such as $.products[0].price.
  6. Use Copy or Download to take the result with you.

JSON Formatter features

Exact error locations

A purpose-built validating parser reports the line, column and a caret snippet for every error, with hints for the mistakes people actually make.

Lossless formatting

Numbers and strings are kept exactly as written, so 1.0 stays 1.0 and 64-bit IDs such as 9007199254740993 are not rounded — a common flaw in formatters built on JSON.parse.

Collapsible tree view

Browse objects and arrays with types, item counts and one-click path copying. Long arrays are drawn in batches so the page stays responsive.

Recursive key sorting

Sort keys alphabetically at every level, which makes two JSON documents easy to compare in the Diff Checker.

Fix common issues

A clearly labelled helper converts single quotes, quotes bare keys, removes trailing commas and comments, and turns Python’s True, False and None into JSON. One click undoes it.

Built for big files

Multi-megabyte files are parsed in a fraction of a second. Live updates pause automatically above about 750 KB so typing never lags.

Common JSON errors and how to fix them

These are the messages you are most likely to see, what causes them and the quickest fix. The “Fix common issues” button handles the first four automatically.

MessageTypical causeFix
Trailing comma[1, 2,] or {"a": 1,}Delete the last comma
Property names must be wrapped in double quotesJavaScript style {name: "Ann"}Write {"name": "Ann"}
Strings must use double quotes'text'Use "text"
Comments are not allowed in JSON// or /* … */ notesRemove them, or keep the file as JSONC
Missing comma between propertiesTwo values with nothing between themAdd a comma
Line break inside a stringA pasted multi-line valueWrite the break as \n
Numbers cannot have leading zeros007 or a PIN/ZIP codeUse 7, or the string "007"

JSON syntax rules in brief

JSON is defined by RFC 8259 and ECMA-404. The rules are short, and almost every validation error breaks one of them:

  • A JSON text is a single value: an object {}, an array [], a string, a number, true, false or null.
  • Strings and property names use double quotes. The only escapes are \" \\ \/ \b \f \n \r \t and \uXXXX.
  • Numbers are plain decimals: no leading zeros, no leading plus sign, no hexadecimal, and no NaN or Infinity.
  • Commas separate items and never follow the last one. Comments are not part of the format.
  • Whitespace between tokens is ignored, which is why formatting and minifying never change the data itself.

When to beautify and when to minify

Beautified JSON is for people: reading API responses, reviewing configuration changes and keeping clean diffs in version control. Two-space indentation is the most common convention in JavaScript projects, while four spaces is the default in Python’s json.dumps(indent=4) style output.

Minified JSON is for machines: request bodies, values stored in databases or local storage, and data embedded in HTML. The status line shows the exact size before and after so you can see what you save. If the JSON is served over HTTP with gzip or Brotli compression, the difference shrinks further, so readable files are usually fine for configuration.

JSON Formatter FAQ

Is this JSON formatter safe for sensitive data?

Yes. Formatting, validation and the tree view run in JavaScript on your own device. Nothing you paste or load is sent to a server, so tokens, keys and personal data stay private — the tool even keeps working if you go offline after the page loads.

Why does my JSON fail validation when it works in JavaScript?

JavaScript object literals are more relaxed than JSON: they allow single quotes, unquoted keys, trailing commas, comments and values like undefined. JSON allows none of these. “Fix common issues” converts most JavaScript-style objects in one click.

Does formatting change my data?

No. Only the whitespace between tokens changes. Strings, numbers and key order stay exactly as written unless you tick “Sort keys A–Z”, and large integers keep every digit.

What does a duplicate key warning mean?

The same property name appears twice in one object, such as {"id": 1, "id": 2}. RFC 8259 says names should be unique; most parsers keep only the last value, so the first is silently lost. The warning lists each duplicate with its line number.

How large a file can I format?

Files of several megabytes format in well under a second on a typical laptop. Above about 750 KB live updating pauses, so press Format instead. The real limit is your device’s memory — phones manage smaller files than desktops.

Can I convert JSON to CSV or YAML?

Yes. Use JSON to CSV for spreadsheets, the YAML ↔ JSON Converter for configuration files and CSV to JSON for the reverse direction.

You might also need