JSON Formatter

Format, validate, minify and repair JSON in your browser. Error line and column, sort keys, collapsible tree view. Free, your data is never uploaded.

Runs in your browser. Your files are never uploaded. How it works

JSON Formatter pretty-prints JSON with clean indentation, checks that it is valid, minifies it for production and repairs common mistakes such as trailing commas and single quotes. Invalid JSON shows the exact line and column of the error. A collapsible tree view lets you explore large API responses. Everything runs in your browser.

How to format JSON

  1. Paste JSON into the box, or click Open file to load a .json file.
  2. Choose the Indent: 2 spaces, 4 spaces or Tab. Tick Sort keys A–Z if you want the keys in alphabetical order.
  3. Click Format, or press Ctrl+Enter (Cmd+Enter on a Mac).
  4. Switch to Tree view to fold and unfold objects and arrays.
  5. Click Copy result or Download .json.

What each button does

Button What it does
Format Pretty-prints the JSON with the chosen indent
Minify Removes every space and line break, for the smallest size
Validate Checks the JSON and points to the first error
Repair Fixes common almost-JSON mistakes, then formats
Tree view Shows the data as a collapsible tree

Finding errors

JSON is strict. A single missing comma or an extra one at the end of a list makes the whole document invalid, and an API or a config loader will refuse it. Validate reports the first problem with its line and column and moves the cursor to that spot in the box. Fix it and validate again until the JSON is valid.

Common causes:

  • Trailing comma after the last item: [1, 2, 3,]
  • Single quotes instead of double quotes: {'name': 'Ann'}
  • Unquoted keys: {name: "Ann"}
  • Comments with // or /* */, which JSON does not allow
  • Python values such as True, False and None
  • A missing comma between two items or two keys

Repair almost-JSON

Data copied from JavaScript code, a Python print-out or a config file with comments is often close to JSON but not quite. Repair fixes all of the mistakes above in one go: it strips comments and trailing commas, converts single quotes, quotes bare keys, and changes True, False and None into their JSON spellings. NaN, Infinity and undefined have no JSON equivalent and become null. Look over the result before you use it, since a repair has to guess what was meant.

Minify for production

Minify removes all whitespace. The result is a single line, often a third smaller or more for deeply indented files, which saves bandwidth in API payloads and keeps config strings short. Format it again whenever you need to read it.

Tree view

Large API responses are hard to read even when formatted. Tree view shows each object and array as a node you can fold and unfold, with the number of items in each. Open only the branch you care about and leave the rest closed.

Tips

  • Compare two JSON files: format both with the same indent and sorted keys, then paste them into Text Compare to see what changed.
  • Base64 inside JSON: decode embedded Base64 strings with Base64 Encode and Decode.
  • Spreadsheet data: to turn a CSV file into a spreadsheet, use CSV to Excel.

Private by design

Your JSON is processed on your own device and never uploaded. That matters for API responses, tokens and customer data. See how it works.

Frequently asked questions

How do I format JSON?

Paste your JSON into the box, or open a .json file, choose 2 spaces, 4 spaces or Tab, and click Format. Ctrl+Enter (Cmd+Enter on a Mac) formats too. Copy the result or download it as a .json file.

How do I find the error in my JSON?

Click Validate. If the JSON is invalid, the tool shows the line and column of the first error and moves the cursor there, so you can fix it straight away. The most common causes are a missing comma, a trailing comma and single quotes.

What does Repair fix?

Repair turns almost-JSON into valid JSON: it removes comments and trailing commas, changes single quotes to double quotes, adds quotes around unquoted keys, and turns True, False and None into true, false and null. NaN, Infinity and undefined become null. Check the result, because a repair is a best guess.

Is my JSON uploaded?

No. Formatting, validation and repair run in your browser. Your JSON is not sent or stored, so API responses with tokens or customer data stay on your computer.

Does sorting keys change my data?

No. Sort keys A–Z only reorders the keys inside each object, at every level. Values and the order of items in arrays stay as they are, and the JSON means exactly the same.

How large a file can it handle?

Files of several megabytes format in a moment. Very large files work too, but the tree view gets slow, so use the text result for those.

More ways to use JSON Formatter

Related tools