Invalid JSON arrives from many directions: a hand-edited config file with a trailing comma after the last property, an API response that quietly wrapped real JSON inside an HTML error page during an outage, a template engine that forgot to suppress a comma when iterating over the final item in a loop, or a serialiser that wrote single-quoted strings because the source data lived in a Python dict.
Loading JSON Validator…
Trailing comma after last element, remove the final comma before ] or }
Single quotes instead of double quotes, replace ' with " around strings and keys
Unquoted keys, add double quotes around all property names
Comments in JSON, JSON does not allow comments; remove any // or /* */ lines
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.
Trailing commas account for roughly half of all JSON syntax errors in practice, by a wide margin over every other category. They appear when developers copy object literals out of JavaScript or TypeScript source code, where trailing commas have been legal since ES5 and are actively encouraged by tools like Prettier and most modern style guides as a clean diff aid. JSON templates that emit a comma after every iteration without suppressing the final one are another common source. The fix is always the same regardless of cause: find the comma sitting immediately before a closing } or ] and delete it. In a large nested file there may be multiple trailing commas at different nesting levels, so fix each one and revalidate to surface the next.
NaN, undefined, and Infinity are JavaScript-specific values that have no equivalent representation in the JSON specification at all. RFC 8259 defines only four primitive types: strings, numbers (which must be finite IEEE 754 values), booleans, and null. A JavaScript serialiser that calls JSON.stringify on an object containing NaN or undefined will either silently drop the offending key or write null in its place, depending on context. A more permissive serialiser that writes NaN literally into the output produces invalid JSON that strict parsers reject. The fix is to replace NaN and Infinity with null, ensure undefined properties are either removed or replaced with a valid value before serialisation, and configure your serialiser to fail loudly rather than emit invalid tokens.
Control characters, meaning ASCII codes 0x00 through 0x1F, must be escaped when they appear inside JSON string values. An unescaped raw newline (0x0A), tab (0x09), or carriage return (0x0D) embedded directly inside a string value is invalid even though the file may look fine in many editors. This error is particularly common with JSON generated by systems that include raw newlines in multi-line text fields like blog post content or log messages. The fix is to replace each raw control character with its JSON escape sequence: \n for newline, \t for tab, \r for carriage return. Other control characters use the \uXXXX four-digit Unicode hex format, for example \u0000 to represent the null byte explicitly.
Fixing invalid JSON one document at a time gets old quickly when the same generator keeps producing the same defects. The durable solution is to add a validation gate in the CI pipeline that runs jq . or python3 -m json.tool over every JSON artifact the build produces, failing the pipeline on the first non-zero exit status. Combined with a pre-commit hook on the developer side, this two-layer defence catches both hand-edited mistakes and generator regressions before either can reach production. For services that emit JSON over the wire at runtime, add a contract test that snapshots a representative response and validates it on every test run, so any future change to the serialiser that breaks JSON validity fails the test suite immediately rather than surfacing as a customer-facing parse error later. Treat invalid JSON as a build-blocking defect, not a runtime curiosity, and the recurrence rate drops sharply.
Paste your invalid JSON and click Validate to get the exact error location and what needs to be fixed.
Step-by-step guide to fix invalid json:
Paste the invalid JSON
Copy the JSON string that is failing somewhere in your stack and paste the entire text into the FixTools validator input. Use the raw bytes rather than a pretty-printed preview from another tool, since the formatter may quietly normalise the content and hide the actual problem your downstream parser is hitting. Include any leading or trailing characters too.
Read the error message
FixTools reports the precise line and column where parsing stopped along with the category of error involved. Common messages include "Unexpected token" naming the specific character found, "Expected comma" when two values appear without a separator, and "Unexpected end of input" when a closing bracket is missing. Read both the position and the description to understand what the parser actually saw.
Fix the error
Correct the issue at the exact reported location. Common edits are: add a missing comma between sibling values, remove a trailing comma sitting before a closing bracket, replace single quotes around a string with double quotes, add double quotes around an unquoted property name, or close an unbalanced bracket. Each fix is usually a one or two character change once you can see the exact spot.
Revalidate
Click Validate again immediately after each individual fix. JSON parsers stop at the first fatal error encountered, so clearing one mistake often reveals additional errors that were hiding behind it deeper in the document. Repeat the cycle of fix and revalidate until the JSON shows as fully valid with no remaining errors anywhere in the input string.
Common situations where this approach makes a real difference:
JavaScript developer
A developer is building a configuration-driven UI where the settings are stored as JSON inside a database column. One config record was inserted at some point in the past by a script that used JSON5 syntax with trailing commas and inline comments. When the UI loads that specific config row, JSON.parse throws and the entire screen crashes. The developer pastes the record value into FixTools, sees three trailing commas and two inline comments flagged with line and column numbers, edits all five in the input panel, revalidates to confirm a clean parse, and updates the database row with the fixed payload.
Python data engineer
A data engineer serialises Python objects to JSON files using the standard library json.dumps function as part of an overnight pipeline. One specific object contains a float value of float("nan") that crept in from a numeric calculation upstream. Python's json module writes NaN directly into the output by default, since the behaviour is configurable, and the resulting file then fails every downstream strict JSON parser. The engineer adds allow_nan=False to the json.dumps call so the serialiser raises a ValueError instead of writing invalid JSON, forcing the NaN to be handled at the source where the calculation produced it.
iOS developer
An iOS developer receives JSON from an internal server that includes a multi-line text field with raw newline characters embedded directly inside a string value. NSJSONSerialization throws a parse error every time. Pasting the problematic payload into FixTools shows the explicit message "Invalid character in string: found unescaped newline at line 6 column 42". The server is inserting raw newline bytes into JSON string content without escaping them first. The correct fix is server-side: escape newlines to \n before inserting any user-provided multi-line text into the JSON structure during serialisation.
Content editor
A content editor updates a JSON-based CMS configuration file using a plain text editor on Windows and saves the change. The CMS rejects the config on the next startup with a vague parse error and refuses to load the new settings. Checking the file in FixTools confirms the JSON itself is syntactically valid against RFC 8259. The real issue turns out to be CRLF line endings the Windows editor wrote, while the CMS parser expects Unix LF endings only. This case illustrates how encoding and line-ending issues can masquerade as JSON errors, and why testing the actual artifact in the actual consumer matters.
Get better results with these expert suggestions:
Fix the source, not just the symptom
When you locate a JSON error in an API response or a generated artifact, trace the problem back to where the JSON is actually produced rather than patching the broken output by hand. A template that generates trailing commas will keep generating them on every run. A serialiser misconfigured to emit NaN will do the same on the next invocation. Fixing the generator at the source prevents the error from recurring on the next deploy or the next request, which is significantly cheaper than chasing it repeatedly.
Use a regex to bulk-remove trailing commas
For large files containing many trailing commas across multiple nested levels, a regex substitution is far faster than fixing each occurrence by hand. The pattern ,\s*([}\]]) matches a comma followed by optional whitespace and a closing bracket or brace, and you replace the entire match with just the captured bracket. Always test the replacement on a copy of the file first to catch any false positives, especially around commas embedded inside string content, and revalidate after to confirm the change cleared the errors.
Check for BOM characters at the file start
Files saved with a UTF-8 byte order mark (U+FEFF) have an invisible character at byte position 0 that breaks strict JSON parsers even though the file otherwise looks completely correct in your editor. This is valid UTF-8 in some contexts but invalid in the JSON specification, which permits no leading bytes before the first JSON value. The BOM looks like a blank line at the very start of your file. Most modern editors offer a save option for UTF-8 without BOM that resolves the issue cleanly.
Distinguish truncated from malformed JSON
If your JSON ends with "Unexpected end of input", the underlying content may be truncated rather than syntactically malformed. Network timeouts, buffer overflows on the producer side, file write interruptions, and storage quotas all produce incomplete JSON that looks broken in the same way as a missing bracket. Before debugging the syntax line by line, confirm the file or response is actually complete by checking its byte length against the expected size or the Content-Length header reported by the server.
More use-case guides for the same tool:
Open the full JSON Validator — free, no account needed, works on any device.
Open JSON Validator →Free · No account needed · Works on any device