esc
No tool matches that yet.
  1. Home
  2. Everyday tools
  3. JSON formatter & validator

JSON formatter & validator

Paste JSON to beautify it, minify it or find out exactly why it won’t parse — with the line, the column and a plain-English reason. Your data never leaves the page, which matters when it is an API response full of customer records.

0 B
Waiting for JSON.
Formatted output appears here.
Big numbers, duplicate keys and key order are preserved when formatting — the text is re-indented, not re-serialised.Ctrl+Enter format · runs locally, nothing uploaded

How to use the JSON formatter

Paste JSON into the Input box — or drag a file onto it — and it is checked as you type. Press Format (or Ctrl+Enter) to pretty-print it with two spaces, four spaces or tabs, or Minify to strip every unnecessary space for the smallest payload. The output has line numbers and syntax colours that stay readable in light and dark mode, and can be copied, downloaded as a .json file or moved back into the input with Use output as input.

Switch the output to Tree to browse a large document: objects and arrays expand on click, show how many keys or items they contain, and long arrays load in pages of 300 so a 50,000-item array doesn’t lock up the tab. Clicking any key copies its path, such as $.orders[1].customer, ready to paste into code.

The search box accepts a key name (every key containing that text, anywhere in the document) or a path with dots, brackets and wildcards: address.city, orders[0], orders[-1] for the last item, or $.orders[*].total to pull one field out of every element.

Reading validation errors

Browsers’ own error messages are terse (“Unexpected token } in JSON at position 1843”). This validator is written for humans: it gives the line and column, shows the offending line with a caret under the exact character, and explains the likely cause. The mistakes it recognises include:

  • Trailing commas — [1, 2, ] is fine in JavaScript but not in JSON.
  • Single quotes and unquoted property names — JSON requires double quotes around every string and key.
  • Comments — // and /* */ are not part of JSON, even though some config files allow them.
  • Python literals — True, False and None from a Python print() instead of json.dumps().
  • Missing commas, mismatched brackets, line breaks inside strings, leading zeros, NaN and undefined, and several top-level values pasted one after another.

Repair fixes the mechanical ones automatically — comments, trailing commas, single quotes, unquoted keys, Python literals — and tells you what it changed. Anything that needs judgement, such as a missing comma, is left for you so nothing is silently guessed.

Big numbers, duplicate keys and why formatting is exact

Most online formatters run JSON.parse then JSON.stringify. That quietly changes your data: JavaScript numbers are 64-bit floats, so an ID like 9007199254740993 becomes 9007199254740992, and when a key appears twice only the last value survives. For database IDs, Twitter/X snowflake IDs or payment references that is a real bug.

Format and Minify here work on the text itself — a streaming scanner re-indents the tokens exactly as written — so numbers keep every digit, duplicate keys stay, and key order never changes. The status line warns you when it sees integers larger than 253 or duplicate keys, because the next program to read the file probably won’t be as careful. Sort keys, the tree, search and CSV necessarily parse the data, so those features follow JavaScript’s rules; the warning tells you when that matters.

FeaturePreserves big integers and duplicates?
Format, Minify, ValidateYes — text is re-indented, not re-encoded
Sort keys, Tree, Search, CSVNo — values pass through JSON.parse

JSON to CSV, escaping and large files

JSON → CSV takes an array of objects (or the first array property of an object, as many APIs wrap results in {"data": [...]}) and builds one column per key across all rows, flattening nested objects into dot-named columns such as address.city. Values starting with =, +, - or @ are prefixed with an apostrophe so Excel and Google Sheets can’t execute them as formulas.

Escape to string turns the input into a JSON string literal, handy for embedding a JSON document inside another or in a test fixture; Unescape string reverses it, which is the fix for log lines full of \". To pass JSON through a URL or an HTTP header, encode it with Base64; for dummy text values in a mock payload, use the lorem ipsum generator.

Everything runs in your browser. Work is split into chunks that yield to the page, so a file of tens of megabytes formats in a few seconds without the tab freezing; above 1.5 MB the output drops syntax colouring to stay fast. The only limit is your device’s memory.

Frequently asked questions

Is it safe to paste confidential JSON here?

Yes. Formatting, validation, search and CSV conversion all happen in JavaScript on your own device; the page makes no network request with your data and stores nothing. That makes it suitable for API responses containing tokens, customer records or internal configuration, which you should never paste into a formatter that sends data to a server.

Why does my JSON fail with ‘trailing comma’ when it works in JavaScript?

JavaScript object literals allow a comma after the last item, but the JSON specification does not, and strict parsers reject it. Remove the comma before the closing bracket, or press Repair, which removes every trailing comma and tells you it has done so.

What is the difference between Format and Minify?

Format adds line breaks and indentation so people can read the structure. Minify removes all optional whitespace, producing the smallest possible file for sending over a network or storing. Both contain exactly the same data, and switching between them never alters values here.

Why did a long number change after I sorted keys?

Sorting requires parsing the JSON into JavaScript values, and JavaScript numbers cannot represent integers above 9,007,199,254,740,991 exactly. Format and Minify avoid this because they work on the original text. If you need sorting as well, store large IDs as strings, which is what most APIs do.

Can it handle JSON Lines or several objects at once?

A JSON document has exactly one top-level value, so several objects pasted one after another are reported as an error at the start of the second one. Wrap them in square brackets with commas between them to make an array, and every other feature, including CSV export, will then work.

How big a file can I format?

Files of tens of megabytes work, limited by your device’s memory rather than by us. The work is done in chunks so the page stays responsive, syntax colouring switches off above 1.5 MB of output to keep scrolling smooth, and files over 200 MB are refused because browsers struggle to hold them.

Everyday tools