JSON Formatter

Format, validate and minify JSON or JSONC, browse it as a tree, and catch duplicate keys and lost precision.

JSON Formatter

On this device

Input

Result

Formatted JSON appears here. Paste yours on the left, drop a file, or try the example.

Ctrl or ⌘ + Enter formats while you type

Runs in your browser — nothing you enter leaves this device.

About this tool

What it does

This tool checks that text is valid JSON and rewrites it with consistent indentation, so nested data becomes readable. It can also minify JSON to a single line, sort object keys alphabetically at every level, and point to the exact line and column when something is wrong. Formatting never changes your data: numbers are kept exactly as written (1.0 stays 1.0, a 64-bit ID keeps every digit), escapes and key order are kept, and a duplicate key is kept and flagged — only whitespace changes, plus comments and trailing commas, which it accepts and removes. It also warns about what other programs will do to your JSON: a duplicate key most parsers reduce to its last value, and an integer beyond 2⁵³ that JavaScript rounds. The tree view folds large documents and copies the JSONPath or JavaScript path to any value; large input is formatted in the background, so the page stays responsive.

How to use it
  1. Paste JSON into the input, open or drop a .json file on it, or press "Try an example" to see how it works.
  2. Choose an indent of 2 spaces, 4 spaces or tabs, and whether to sort keys.
  3. Press "Format JSON" — or Ctrl + Enter (⌘ + Enter on a Mac) while typing.
  4. If the JSON is invalid, the error names the line and column; press "Show in input" to put the cursor on it, fix it and format again.
  5. If the whole input is JSON saved inside a string (escaped quotes, as in many logs), press "Unescape" to get the object back.
  6. Read any notes above the result: comments removed, duplicate keys, or numbers that changed.
  7. Switch to Tree to fold and unfold the structure, and press the copy icon beside any value for its path.
  8. Copy the result, or download it as a .json file.
Limits and your data
  • Input is limited to 5 MB. Very large files are better handled in a desktop editor.
  • Syntax colouring is switched off for outputs over 200 KB so the page stays responsive.
  • Comments and trailing commas (JSONC, as in tsconfig.json or VS Code settings) are accepted and removed, and the output says so. Valid JSON is never altered this way. Single quotes, unquoted keys and other JSON5 extras are still errors, with a hint naming the cause.
  • Numbers beyond JavaScript’s safe integer range (about 9 × 10¹⁵) are kept exactly in the formatted output, but JavaScript — and the tree view — read them as a rounded value. Each one is listed with that value, so you can send it as a string instead.
  • Very deeply nested JSON (thousands of levels) can be minified but not indented, because the indentation alone would exceed the longest text a browser can hold.
  • The tree shows 100 children at a time for each object or array; press “Show more” for the rest.
  • Formatting happens inside this page. Your JSON is not uploaded, logged or saved, and closing the tab discards it. Even so, avoid pasting live secrets such as API keys or access tokens into any website.

Questions

Does my JSON with a trailing comma work?

Here, yes: a trailing comma is removed and the output notes it. Standard JSON doesn’t allow one, though, so the formatted output (without it) is what you should send to an API. Most JSON.parse implementations will reject the original.

Can I use comments in JSON?

Not in standard JSON. JSONC, the format of tsconfig.json and VS Code settings, allows // and /* */ comments. This formatter accepts them, removes them, and says how many it removed, so the output is strict JSON.

Why does my ID end in 00 in my JavaScript app?

JavaScript stores numbers as 64-bit floating point, which holds integers exactly only up to 9,007,199,254,740,991. A larger ID, such as a Snowflake or bigint key, is rounded by JSON.parse in every browser. The formatted output here keeps every digit, and the note above the result shows the rounded value a JavaScript program would see. The fix is on the producing side: send such IDs as strings.

Does sorting keys change my data?

It changes only the order of keys inside objects, which JSON treats as meaningless. Array order is always kept, because it does carry meaning.

Is it safe to paste private data?

Nothing leaves your browser, which you can confirm in the network tab. For credentials and production tokens, the safest habit is still not to paste them into any web page.