Skip to content
cliplimeClipLime

Your JSON is one unreadable line, or the parser says "unexpected token at position 412". Find out what is wrong

Paste it, get it indented, and read the line and column of what the parser choked on. Then the seven mistakes behind most invalid JSON.

6 min readUpdated October 27, 2026

Skip the readingJSON Formatter: Pretty print, minify and validate JSON, with the line and column of any error.

The quick answer

The API response is one unreadable line, or your code stopped with a message like Unexpected token } in JSON at position 412 (older wording, newer browsers and Node phrase it differently) and you cannot tell what sits at position 412. Paste the text into the JSON formatter. Valid JSON comes back indented. Invalid JSON gets the line, the column and a likely cause.

  1. Paste the JSON into the left box, or drop a .json file on it. The result updates as you type.
  2. Choose Format, then an indent of 2 spaces, 4 spaces or tabs.
  3. If the JSON is invalid, an error message gives the line, the column, the faulty line and a likely cause. Go to line jumps straight to it.
  4. Fix that one problem and the result updates. Then copy it or download it.
JSON FormatterPaste your JSON, get it indented and checked, with the line and column of any error.Open it

The seven reasons JSON is invalid

JSON grew out of JavaScript object syntax but kept only a small part of it. Many "invalid JSON" errors are one of these seven, and each fix is a character or two.

What went wrongInvalidValid
Trailing comma{"a": 1, "b": 2,}{"a": 1, "b": 2}
Single quotes{'name': 'Ann'}{"name": "Ann"}
Unquoted key{name: "Ann"}{"name": "Ann"}
Comment{"a": 1, /* count */ "b": 2}{"a": 1, "b": 2}
Quote or line break inside a string{"say": "She said "hi""}{"say": "She said \"hi\""}
NaN, undefined, True or None{"n": NaN, "ok": True}{"n": null, "ok": true}
Curly quotes or a hidden character{“a”: 1}{"a": 1}
  • Trailing commas and comments are fine in JavaScript and in files such as tsconfig.json (a relaxed form called JSONC), but not in JSON. If your file is meant to allow them, turn on Allow comments and trailing commas. Comments are dropped from the result.
  • Single quotes and bare keys are what you get when you copy a printed Python dictionary or a JavaScript object literal. JSON has only lowercase true, false and null, so Python's True, False and None fail too.
  • A string cannot hold a raw quote, line break or tab. Write \", \n and \t. A Windows path such as C:\Users\ann fails at \U. Worse, C:\temp is valid and quietly decodes as C:, a tab and emp.
  • NaN, Infinity and undefined are not JSON values. They usually come from a serializer: Python's json.dumps writes NaN by default, while JavaScript's JSON.stringify writes null for it. Use null or leave the key out.
  • Curly quotes, non-breaking spaces and a byte order mark look fine on screen and arrive when you copy from a document, a chat app or a web page. The checker names the curly quotes and the lookalike space. A byte order mark at the very start is removed, with a note.
  • Also common: a missing comma between items (look at the end of the previous line) and leading zeros such as 007, which need quotes if they are IDs.

How the tool shows where the problem is

A parser's own message often gives only a character position. The formatter reports the line and column, shows the faulty line and says what is likely wrong. It shows only the first problem, because later ones are often side effects of it.

  • "This looks like HTML or XML, not JSON" means the first character was <. An API sent back a web page or an error page instead of data. Check the URL and status code, not the commas.
  • "This object is never closed" points at the opening brace, not the end of the text, so you can find the pair that lost its partner.
  • "Extra content after the end of the JSON value" usually means JSON Lines, one value per line. Put the lines in an array with commas between them.

Format, validate or minify?

Each mode has its own page: the JSON validator gives a verdict and a report, and the JSON minifier gives the shortest text.

ModeUse it whenYou get
FormatYou need to read a response, a log line or a configLine breaks and indentation, with every string and number copied as written
ValidateYou want a verdict, or a summary of what is insideValid, or the error, plus root type, size, nesting depth and counts, with warnings for duplicate keys
MinifySize matters: a request body, an environment variable, a value in a URLSpaces and line breaks outside strings removed, with the bytes saved

"Copied as written" matters more than it sounds. Many formatters read JSON into JavaScript values and write it back, which turns 1.0 into 1 and can round integers above 9,007,199,254,740,991. This one copies each number and string exactly, keeps duplicate keys and reports them, and warns when a number has more digits than a JavaScript number can hold. Put IDs that must stay exact in strings.

Minifying saves less on the network than it looks, because servers usually compress responses with gzip or Brotli, and a minified file is one long line, so keep repository files formatted. Sorting property names A to Z puts two objects with the same keys in the same order, which helps when you compare them with a text diff. Arrays are never reordered.

What it cannot do

  • It checks syntax, not meaning. It cannot tell you that email is missing or that age is a string. That needs a JSON Schema and a validator that reads it, and the syntax check comes first.
  • It does not repair JSON. It points at the first problem and does not guess, because a wrong guess can change your data without you noticing.
  • It is not JSON5. The relaxed option adds only comments and trailing commas. Unquoted names, single quotes and hex numbers are still errors.
  • Very large input waits for a button. Up to 2 million characters the result updates as you type. Longer text runs when you press it.

Keep API responses and tokens on your device

Real responses hold session tokens, email addresses, customer records and keys. Many free formatters send what you paste to a server. Here the formatting runs in your browser tab. To check, open your browser's developer tools, go to the Network tab, paste some JSON and watch: no request goes out carrying your text.

A JSON Web Token is the classic case. In the usual signed form, its header and payload are only Base64 encoded, not encrypted, so anyone who holds the token can read them, and a live token works like a password until it expires. The JWT decoder also runs in your browser and checks a signature only if you type an HS256, HS384 or HS512 secret. Even so, use a test token when you can. Decode a JWT token explains the claims and why decoding is not verifying, and Base64 explained shows why the parts are readable. The same question for documents is answered in is it safe to upload a PDF to a free website.

Where to go next

If the config is YAML, the YAML formatter re-indents and checks it, keeps your comments and never rewrites values such as 0755 or yes. To move data between JSON and a spreadsheet, use the Data Converter and read the guide to converting CSV to Excel and JSON. To pull a value out of messy text before you format it, test a regular expression first.

JSON ValidatorGet a verdict, the line and column of any error, and a report of what is inside.Open it

Try it yourself

Questions people ask

Why is my JSON invalid?

Usually one of seven things: a trailing comma, single quotes, an unquoted key, a comment, a raw quote or line break inside a string, NaN or undefined, or an invisible character such as curly quotes. Paste it into the JSON validator to get the exact line and column.

How do I pretty print JSON?

Paste it into the JSON formatter, choose Format, and pick 2 spaces, 4 spaces or tabs. Only the white space changes. In code, JSON.stringify(value, null, 2) does the same, but it works on parsed values, so very large integers can be rounded first.

What does "unexpected token at position 412" mean?

The parser met a character it did not expect, 412 characters from the start. Wording and numbering differ between browsers and languages, and the real cause is often just before it, such as a missing comma. The formatter gives a line and column instead. If the token is <, you received an HTML page, not JSON.

Can it fix broken JSON automatically?

No. It shows the first problem and the likely cause, but it does not guess a repair, because a wrong guess can change your data silently. If the file is meant to hold comments or trailing commas, turn on the relaxed option to read it.

Is it safe to paste API responses or tokens?

The text is formatted in your browser tab and not uploaded, which you can confirm in the Network tab of your developer tools. Treat live tokens like passwords anyway, and prefer test data when you can. The JWT decoder works the same way.

Does minifying change my data?

No. Only white space between values is removed, and strings and numbers are copied exactly. The exceptions are sorting property names and the relaxed option, which drops comments and trailing commas. Both are off by default. Use the JSON minifier for a request body, an environment variable or a value stored in a URL.

All Data and developer guides Browse all data & developer tools