JSON Formatter

Beautify, minify and validate JSON with exact line and column errors, a collapsible tree view and big integers kept intact. Free, no sign-up, no uploads.

  • Line & column errors
  • Collapsible tree view
  • Big integers kept
  • One-click minify
Tree view

Enter valid JSON to see a collapsible tree here.

Your data is processed in your browser and never uploaded or saved.

🔒 Everything is calculated in your browser. No data is sent to any server.

When to use it

  • API debugging: Pretty-print a one-line API response into readable JSON and find fields in the tree view.
  • Fixing config files: When a comma or quote is missing, see the exact line and column of the error.
  • Minifying before deployment: Squeeze JSON onto one line in one click to cut file size or paste it into code.
  • Tidying before a diff: Tick “Sort keys” so two JSON files have the same key order, then compare them with a text diff tool.

How to use

  1. Paste JSON into the left box or click "Open file" to load a .json file. Syntax is checked as you type, and the tree view on the right updates live.
  2. Pick an indent (2 spaces, 4 spaces or tab) and click "Format" for readable multi-line output, or "Minify" to squeeze it onto one line. Tick "Sort keys" to order every object's keys alphabetically.
  3. If there's a syntax error, you'll see the exact line and column. Click "Show error" to select the offending character, then use "Copy" when you're done.

Worked example

Trailing comma: entering the four lines {, "name": "Pockez",, "tags": ["json", "tool"],, and } reports "Line 4, column 1: there's a comma after the last item". The error points at the closing }, but the comma to delete is at the end of line 3.

Big integers stay exact: for {"orderId":9007199254740993,"price":1.50}, JavaScript's JSON.parse returns 9007199254740992 and a price of 1.5. After formatting here you still get 9007199254740993 and 1.50, plus a note that 1 integer is beyond the safe range.

Sorting keys: format {"name":"Alice","age":30,"tags":["a","b"]} with "Sort keys" ticked and a 2-space indent, and the keys come out as age, name, tags, while the a and b inside the tags array keep their order.

Reading the results

  • "Valid JSON" means the whole document follows the JSON standard (RFC 8259), so any programming language can read it.
  • The line and column in an error mark the first spot the parser couldn't understand. The real fix is often just before it: a missing comma, for example, is reported at the start of the next key.
  • In the tree view, { 3 } means an object with 3 fields and [ 2 ] means an array with 2 items. Numbers with a dotted underline are big integers; hover for details.
  • A big-integer note doesn't mean your data is wrong. It means a receiver that reads numbers as double-precision floats, like JavaScript, will lose precision, so consider sending those values as strings or reading them with BigInt.

How it works

  • A purpose-built parser reads the text character by character using the RFC 8259 and ECMA-404 grammar and stops at the first error. It doesn't rely on the browser's JSON.parse, so error positions and messages are the same in every browser.
  • Formatting and minifying only rearrange whitespace. Strings keep their original escapes (\u00e9 stays \u00e9), numbers keep their original spelling (1.50 and 1e400 are untouched), and key order and duplicate keys are preserved.
  • Sort keys orders every object recursively by UTF-16 code unit, the same as JavaScript's default sort. Duplicate keys keep their relative order, and arrays are never reordered.
  • Integers whose absolute value exceeds 2^53−1 (9007199254740991) are flagged as big integers. Numbers with a decimal point or exponent are not flagged.

Limitations

  • Only strict JSON is accepted. Comments, trailing commas, single quotes, NaN, undefined and other JSON5 or JavaScript syntax are reported as errors.
  • Only the first error is reported at a time; fix it and the check moves on to the next one.
  • Nesting deeper than 1000 levels stops parsing with a message instead of freezing the browser.
  • Files of tens of megabytes can slow the browser down. The tree view only opens the first two levels; "Expand all" builds every node, so for big files open just the parts you need.

FAQ

Why is my JSON invalid?

The usual suspects are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, // comments, or values like undefined and NaN. JavaScript accepts these, but standard JSON doesn't. The error message tells you where and why.

Will large numbers get changed?

No. Many online tools run your data through JavaScript's JSON.parse, which silently rounds integers above 9007199254740991, so an ID like 9007199254740993 becomes ...992. This tool keeps the original digits and tells you how many such big integers it found.

Does formatting change my data?

No. Formatting and minifying only change whitespace and line breaks. Strings, number spellings such as 1.50, and key order stay exactly as written. Key order only changes when you tick "Sort keys", and array order never changes.

Is my data uploaded?

No. Parsing, formatting and the tree view all run in your browser. Nothing is sent to a server or stored, so it's safe to use with config files that contain personal data or API keys.

Can JSON have comments?

Standard JSON doesn’t support // or /* */ comments; they’re reported as errors. Config files that need comments usually use JSONC, JSON5 or YAML instead.

How do I convert JSON to Excel or CSV?

Use this site’s CSV to JSON Converter: choose “JSON → CSV”, paste your data and download the CSV to open in Excel (keep “Add BOM” on so accented and non-English characters display correctly).

What’s the difference between JSON and a JavaScript object?

JSON is a plain-text data format: keys must use double quotes, trailing commas aren’t allowed, and functions or undefined can’t be included. JavaScript object syntax is much more relaxed.

References