JSON Formatter

Format, validate and minify JSON, explore it as a tree, and copy it as a TypeScript interface. Formatting never changes your data, and nothing you paste leaves your browser.

  • Never rounds your numbers
  • Errors with line and column
  • Tree view and TypeScript

Type

Object

Nodes

19

Depth

4

Size

284 bytes

Status

Valid JSON

Input

Tab indents. Press Esc, then Tab, to move to the next control.

{ "user": { "id": "usr_88231", "display-name": "Alex Developer", "roles": [ "admin", "editor" ], "verified": true }, "settings": { "theme": "dark", "notifications": { "email": true, "push": false, "frequency": "daily" } }, "stats": { "loginCount": 42, "lastActive": "2026-05-06T12:00:00Z", "score": 9.5, "referrer": null } }

What you can do with it

Paste JSON and it is checked as you type. Format re-indents it with 2 spaces, 4 spaces or tabs, and Minify strips every unnecessary space. Sort keys orders every object alphabetically, the Tree tab lets you open and close nested parts, and Download saves the formatted result as a .json file. Pasting a single-line JSON document formats it automatically.

Why formatting should never change your data

The usual way to pretty-print JSON is to parse it and write it back out. That quietly changes things: whole numbers larger than 9,007,199,254,740,991 are rounded (a database ID can end up wrong), keys that look like numbers are reordered, and duplicate keys disappear. Here, Format and Minify only change whitespace, so every value comes out exactly as it went in.

When your JSON contains numbers that JavaScript cannot hold exactly, the tool tells you. They stay exact in the formatted text; the tree and TypeScript views, and Sort keys, work with approximate numbers, so Sort keys is switched off for those documents.

Reading an error

JSON is strict, and a single stray character makes the whole document invalid. The error panel shows the line and column and the line itself with a marker underneath. The mistakes behind most errors are the same few:

  • A trailing comma after the last item in an object or array.
  • Single quotes instead of double quotes, or property names without quotes.
  • Comments, which JSON does not allow.
  • A missing comma between two items.
  • NaN, Infinity or undefined, which are not valid JSON values.

TypeScript from JSON

Copy as TypeScript turns your document into an interface you can paste into code. It quotes keys that are not valid names, such as "user-id", describes arrays of mixed values as unions, and keeps null as null. Because it only sees one example, it cannot know which fields are optional or which strings are really dates or enums, so treat the result as a starting point.

Frequently asked questions

Is my JSON uploaded?

No. Everything runs in your browser, so tokens, customer data and API responses you paste are never sent to a server.

Does formatting change my data?

No. Format and Minify work on the text itself, so large numbers, key order and duplicate keys stay exactly as you wrote them. Many formatters parse and rewrite the JSON instead, which can round a large ID such as 12345678901234567890 without telling you.

How do I find a syntax error?

The tool shows the line and column and the offending line with a marker, with a plain explanation such as a trailing comma, single quotes, an unquoted key, a comment or a missing comma.

What does Copy as TypeScript do?

It builds an interface from your JSON. Keys that are not valid names are quoted, arrays of mixed values become unions, and null stays null. It works from the one sample you give it, so it cannot tell which fields are optional; review the result before using it.

Can it fix invalid JSON for me?

No. It tells you exactly what is wrong and where, so you can fix it without the tool guessing and changing your meaning.

How big a document can I use?

It depends on your device's memory. Documents of several megabytes work, and for large ones the tree view starts collapsed so it stays responsive.

More tools like this

All tools →