JSON Formatter and Validator

Paste JSON to format it with 2 spaces, 4 spaces or tabs, or minify it to one line. The formatter validates as you type and points to the exact line and column of any error, such as a trailing comma or single quotes.

Characters
0
Words
0
Lines
0

Your text never leaves your device.

How to use

  1. Paste your JSON, for example an API response or a config file.
  2. Choose 2 spaces, 4 spaces, Tabs or Minify. Valid JSON is formatted instantly; invalid JSON shows the line, column and reason.
  3. Copy the result or download it.

Examples

  • Before
    {"name":"Ada","tags":["math","code"],"id":12345678901234567890,"active":true}
    After
    { "name": "Ada", "tags": [ "math", "code" ], "id": 12345678901234567890, "active": true }
  • Before
    { "name": "Ada", "tags": [ "math", "code" ] }
    After
    {"name":"Ada","tags":["math","code"]}
  • Before
    {"a": 1,}
    After
    Line 1, column 8: trailing comma. JSON does not allow a comma before } or ].

Formatting options

  • 2 spaces: the default in JavaScript and TypeScript projects, npm’s package.json and most style guides.
  • 4 spaces: common in Python projects (json.dumps with indent=4) and in Java and C# codebases.
  • Tabs: one character per level, and each reader’s editor decides how wide it looks.
  • Minify: removes all whitespace outside strings. Use it for payloads, environment variables and anywhere size matters; deeply nested files often shrink by a quarter or more.

Formatting never changes the data. Keys keep their order, strings keep their escape sequences exactly as written (an escaped é stays escaped), and numbers keep their exact digits.

Common JSON errors and how to fix them

Error message Typical cause Fix
trailing comma [1, 2, 3,] delete the last comma
single quotes {'a': 1} use double quotes for keys and strings
unexpected character unquoted key {a: 1}, undefined, NaN, +1, .5 quote the key; use null for missing values; write 1 and 0.5
extra data after the end a comment, or two objects one after another remove comments; wrap several objects in an array
invalid number a leading zero: 01.50, 007 write 1.50 and 7, or make the value a string
a string is not closed a missing closing quote, or a raw line break inside a string add the quote; write line breaks as \n
tabs and other control characters a tab pasted inside a string replace it with \t

Columns count characters as you see them, so an emoji earlier on the line counts as one column.

Common mistakes

  • Pasting a JavaScript object. Code like { name: 'Ada' } is valid JavaScript but not JSON. Quote the keys and switch to double quotes.
  • Comments in config files. Standard JSON has no comments. Files like tsconfig.json accept them because their tools use a relaxed parser (JSONC); strict parsers and this validator reject them.
  • Validating only the format. Valid JSON can still have the wrong structure for your API. Check the field names and types against the API’s documentation or schema.

Frequently asked questions

How do I format JSON?

Paste it into the box above. If it is valid, it is formatted immediately with 2-space indentation; choose 4 spaces or tabs if your project uses them. If it is not valid, the status line shows the line and column of the first error and what is wrong there.

Why is my JSON invalid?

The most common causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, comments (// or /* */), and values like undefined, NaN or .5. All of these are allowed in JavaScript but not in JSON. The error message names the problem and its position.

Does the formatter change my numbers?

No. Many online formatters run JSON.parse, which turns 12345678901234567890 into 12345678901234567000 and 1.0 into 1, because JavaScript numbers have only about 16 significant digits. This formatter re-indents the original text instead, so every number, string escape and key stays exactly as you wrote it, including duplicate keys.

Is it safe to paste JSON with API keys or customer data?

Yes. Formatting and validation happen in your browser and nothing is uploaded or logged. That is worth checking with any online tool, since API responses and config files often contain tokens and personal data.

Can it handle large JSON files?

Yes. Inputs larger than about 500 KB are formatted in a background thread, so the page stays responsive; a 5 MB file formats in well under a second on a typical laptop. The preview shows the beginning of very large results, while Copy and Download always give the complete output.