JSON Formatter

Format, beautify and minify JSON with 2/4-space or tab indentation, sorted keys and a collapsible tree view. Big numbers stay exact. Private.

Paste messy or one-line JSON and get clean, readable JSON instantly — or squeeze it into a single line with Minify. Choose 2 spaces, 4 spaces or tabs, sort keys alphabetically, and switch to the tree view to fold large documents and copy the exact path of any value.

The formatter runs entirely in your browser, so API responses, tokens and configuration files never leave your device. Unlike many online formatters it keeps numbers exactly as written: an ID like 12345678901234567890 is not silently rounded.

How to use JSON Formatter

  1. Paste your JSON into the input box, drop a .json file onto it, or click “Open file”.
  2. The formatted JSON appears on the right as you type. Pick 2 spaces, 4 spaces or Tab, and tick “Sort keys A–Z” if you like.
  3. Click Minify for a compact single line, or switch the view to Tree to fold and explore the structure.
  4. Copy the result or download it as a .json file.

Features

  • Beautify with 2 spaces, 4 spaces or tabs; minify to one line.
  • Sort object keys alphabetically at every level.
  • Big numbers and decimals are kept exactly as written — no rounding of long IDs.
  • Clear error messages with line and column, plus “Try to fix” for comments, trailing commas, single quotes and unquoted keys.
  • Tree view: fold objects and arrays, click any value to copy its JSONPath (for example $.tools[1].id).
  • Warns about duplicate keys, which most programs silently drop.
  • Escape text as a JSON string, or unescape a JSON string back to text.
  • Handles large files (10 MB and more) without freezing the page.
  • No upload, no sign-up — works offline once the page has loaded.

What is JSON?

JSON (JavaScript Object Notation) is the most common format for exchanging data between web services, apps and configuration files. It is plain text built from just a few pieces: objects in curly braces holding "key": value pairs, arrays in square brackets, text in double quotes, numbers, true, false and null.

Because JSON is often sent without any line breaks to save space, a formatter (also called a beautifier or pretty printer) adds indentation and line breaks so people can read it.

Formatting vs minifying JSON

Formatting adds line breaks and indentation so each key sits on its own line — ideal for reading, reviewing and comparing. Minifying removes every unnecessary space, making the file smaller and faster to send. Both contain exactly the same data.

Formatted (beautified)Minified
Best forReading, debugging, code review, documentationAPIs, storage, sending over the network
SizeLarger (spaces and line breaks)Smallest possible
Example{ "id": 1, "ok": true } split over lines{"id":1,"ok":true}
Same data?YesYes

Common JSON errors and how to fix them

Most invalid JSON comes from a handful of mistakes, usually made when JSON is written by hand or copied from JavaScript code. The formatter points to the exact line and column, and “Try to fix” can repair the common ones automatically.

ErrorWrongRight
Trailing comma[1, 2, 3,][1, 2, 3]
Single quotes{'name': 'Ann'}{"name": "Ann"}
Unquoted key{name: "Ann"}{"name": "Ann"}
Comments{"a": 1 // note}{"a": 1}
Python values{"ok": True, "x": None}{"ok": true, "x": null}
Leading zero{"n": 07}{"n": 7}
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}

Why big numbers matter

JavaScript stores numbers with about 15–17 significant digits, so many tools that use JSON.parse quietly change long values: 12345678901234567890 becomes 12345678901234567000. That breaks database IDs, order numbers and Twitter/X-style snowflake IDs.

This formatter reads the text itself and writes every number back exactly as it was, including trailing zeros such as 1.50 and exponents such as 2.5E+10.

Is it safe to paste private JSON here?

Yes. The formatter is a small program that runs in your web browser. Your JSON is never uploaded, logged or stored on a server — you can even disconnect from the internet after the page has loaded and it keeps working. That makes it suitable for API responses, access tokens and configuration files that contain secrets.

Frequently asked questions

Is this JSON formatter free?

Yes, completely free with no sign-up and no limits on size or how often you use it.

Is my JSON uploaded to a server?

No. Formatting happens in your browser on your own device. Nothing you paste is sent anywhere.

What is the difference between a JSON formatter and a JSON validator?

A formatter re-indents valid JSON so it is easy to read (and reports errors if it is invalid). A validator focuses on checking: it explains every error and can also check your data against a JSON Schema. Use the JSON Validator for schema checks.

Should I use 2 spaces, 4 spaces or tabs?

It is a matter of taste: 2 spaces is the most common for JSON (used by npm and most APIs), 4 spaces is common in Python projects, and tabs let each reader choose the width. The data is identical.

Why does the formatter say my JSON is invalid?

Usually because of a trailing comma, single quotes, an unquoted key or a comment — all allowed in JavaScript but not in JSON. The message shows the line and column; click “Try to fix” to repair the common cases automatically.

Does sorting keys change my data?

No. JSON objects are unordered, so sorting keys only changes the order in which they are written. It is useful for comparing two JSON files or keeping configuration tidy.

Can it handle large JSON files?

Yes. Files over 1 MB are processed in the background so the page stays responsive; files of 10 MB and more format in a second or two on a normal computer.

What is a JSONPath?

A short address of a value inside a JSON document, such as $.tools[1].id (the id of the second item in tools). In the tree view, click any value to see and copy its path — handy for code, jq queries and test assertions.

What are duplicate keys and why the warning?

JSON allows the same key twice in one object, but most programs keep only the last value and silently lose the first. The formatter warns you so you can find and remove the duplicate.

Related tools