A JSON parse error tells you something went wrong but rarely tells you what to do about it.
Loading JSON Validator…
Converts character positions to line and column
Explains what caused the unexpected token
Identifies all common parse error types
Free, no installation, browser-based
Drop the JSON Validator into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/json/json-validator?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="JSON Validator by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
The phrase Unexpected token appears in JSON parse errors whenever the parser encounters a character that does not match the grammar rule it is currently evaluating. The character is named in the message as the token. The most common unexpected tokens have well-defined human causes. A closing brace or bracket means there is a trailing comma immediately before that closing character. A single quote means a developer used single-quoted strings where the grammar requires double quotes. A leading letter that opens a word like undefined, NaN, True, or None means a serialiser produced a literal that JSON does not recognise. A less-than sign at position zero means the response was actually HTML, not JSON.
The position in the error message is a character offset from the start of the buffer, counting from zero. Converting offset to line and column requires walking the string character by character, counting newlines and resetting the column on each line break. Most engines report the offset accurately at the character that broke the parse. The exception is the trailing comma case: the parser does not realise the comma was trailing until it encounters the closing bracket, so the reported position lands on the closing bracket rather than on the comma itself. Knowing this saves you from staring at a correct-looking closing brace and wondering what is wrong with it.
After locating the unexpected character, the next step is to compare what was found against what the grammar expected. Expected comma between values means two values appeared back to back with no separator. Expected closing bracket means the parser counted more open brackets than it found close brackets. Expected string means a property name was not wrapped in double quotes, or the parser was looking for a string and found a different value type. Expected value means a comma was followed by a closing bracket, which is the trailing comma signature. FixTools reports both the found and the expected character, so the fix is determined rather than guessed.
Once a parse error is diagnosed and fixed in the moment, the durable next step is to prevent the same class of error from recurring by wiring validation into a CI pipeline. A typical GitHub Actions job runs jq . over every JSON file changed in a pull request and exits non-zero on the first failure, blocking the merge. For projects with many JSON fixtures, a pre-commit hook using the standard check-json hook from the pre-commit framework catches the failure on the developer machine before it even reaches the remote repository. For runtime JSON crossing the wire from external systems, a validation middleware that catches parse failures and returns a structured 400 response avoids leaking SyntaxError stack traces to clients. Each layer turns a recurring debugging cost into a one-time configuration cost. The savings compound across the team because every developer benefits from every previous fix without having to learn the same lesson independently.
Paste the JSON that is giving you a parse error. FixTools shows the line, column, unexpected token, and what was expected, making the fix clear.
Step-by-step guide to json parse error fixer:
Copy the failing JSON
Capture the exact JSON string that triggered the parse error in your code. Add a console.log of the input immediately before the parse call so the captured value matches what the parser actually saw, including any invisible bytes the surrounding code may have introduced. Copy from the log rather than from the original source to be sure.
Paste into FixTools
Paste the captured string into the FixTools JSON validator input area. Confirm the length and the first few characters match your expectations to rule out clipboard truncation. If the string came from JSON.stringify in your log, strip the outer quotes and unescape the embedded quotes before pasting so the validator processes the same bytes the parser did.
Read the error details
FixTools reports three pieces of information for every error: the line and column where parsing failed, the unexpected character that was found, and the character or token type that the grammar expected at that point. Read all three together. The combination tells you whether the fix is a single character deletion, a quote replacement, or a content-type investigation.
Fix at the reported location
Navigate to the exact line and column in your source editor. Apply the fix that matches the token type: delete the trailing comma before a closing bracket, replace single quotes with double quotes, change a NaN to null, or trace back to where the JSON was generated when the issue is at position zero. Save the file and prepare to revalidate.
Revalidate
Paste the updated JSON into FixTools and run validation again. JSON parsers fail fast, so one error can hide others further down. Repeat the fix-and-revalidate cycle until the validator returns a green result. Only then update the source generator so the same failure does not recur on the next record produced by the same pipeline.
Common situations where this approach makes a real difference:
DevOps engineer
A deployment pipeline fails with a JSON parse error at position 1823 in a Helm values file. The engineer cannot tell which line that is. They paste the file into FixTools, which reports the error at line 47 column 3 with the message Unexpected closing bracket, expected value. The trailing comma on line 46 closed a list prematurely. Removing the comma lets the deploy proceed, and the engineer updates the Helm chart template that produced the comma so the same failure does not block the next release.
Front-end developer
A React app throws SyntaxError: Unexpected token 'undefined' at runtime when reading a cached response. The developer logs the cached string before parsing, pastes it into FixTools, and sees the literal text undefined where a value should be. The cache writer serialised an undefined object property without converting it to null. The fix is to add a replacer to the JSON.stringify call that converts undefined to null so the cache content always validates on read.
Backend developer
An Express API receives a request body that fails parsing in the express.json middleware. The developer captures the failing body and pastes it into FixTools. The validator reports an open parenthesis at position zero, meaning the body is JSONP-wrapped rather than plain JSON. The client is sending the wrong content type because of a misconfigured fetch call. The fix is in the client, not the server, and the team adds a content-type check to the middleware to surface this category of error more clearly in future.
QA engineer
A QA engineer is reproducing a production bug where a JSON import fails for a small group of users. They download the file from one affected user environment and paste it into FixTools. The validator reports NaN at line 103 in a numeric field where the sensor reading was missing. The data pipeline that generates these files writes NaN instead of null when a sensor times out. The fix is in the pipeline, and the QA engineer adds a regression test that replays the affected file shape.
Get better results with these expert suggestions:
Fix errors from the top down
JSON parsers stop at the first fatal error, so the error reported is always the earliest failure in the buffer. Fix that one first and revalidate. Errors earlier in the file frequently cause the parser to misinterpret everything that follows, which produces misleading secondary error messages. Trying to address all reported issues in a single editing pass without revalidating in between often introduces new errors that did not exist before you touched the file.
Unexpected closing bracket means trailing comma
When the error says Unexpected token } or Unexpected token ] and the position lands on the closing character, look at the character immediately before it in the source. A comma sitting between the last value and the closing bracket is almost always the cause, and the parser only realised the comma was trailing once it reached the bracket. The fix is to delete the comma, not to add a new value, and not to remove the bracket.
Check for NaN and undefined in serialised output
When JSON comes from JSON.stringify and still fails to parse on the receiving side, the source object likely contained NaN, undefined, or Infinity in some field. JSON.stringify writes Infinity and NaN as null automatically, but some hand-written serialisers in other languages or in older libraries write them literally. Add an assertion in the producing code that rejects these values before serialisation rather than waiting for the consumer to fail.
Use a hex viewer for invisible character errors
When the error position points to a character that looks completely correct in your editor, the buffer almost certainly contains an invisible Unicode character at that location. A hex viewer or a Unicode code point inspector reveals zero-width spaces at U+200B, non-breaking spaces at U+00A0, byte order marks at U+FEFF, and directional formatting marks at U+200E and U+200F. Remove the invisible character or escape it as a Unicode escape sequence inside a string.
More use-case guides for the same tool:
Other tools you might find useful:
Open the full JSON Validator — free, no account needed, works on any device.
Open JSON Validator →Free · No account needed · Works on any device