Skip to content

JSON Formatter

Format, validate, minify and sort JSON, with errors pinned to the line.

Input

Result

Formatted JSON appears here. Paste yours on the left, or try the sample.

Ctrl + 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.

How to use it
  1. Paste JSON into the input, or press "Try a sample" 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; fix it and format again.
  5. 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.
  • It follows strict JSON: comments, trailing commas and single-quoted strings are errors, as they are in JSON.parse.
  • Numbers beyond JavaScript’s safe integer range (about 9 × 10¹⁵) lose precision, as they would in any browser.
  • 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

Why does my JSON with a trailing comma fail?

Standard JSON does not allow a comma after the last item in an object or array. Remove it and format again — the error message points to the line where the parser stopped.

Can I use comments in JSON?

Not in standard JSON. Formats such as JSONC or JSON5 allow them, but a strict parser rejects them. Remove the comments to validate the data.

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.