Why A JSON Formatter Reports Invalid JSON

Diagnose JSON syntax failures involving commas, quotes, brackets, comments, BOMs, trailing material, scalar roots, and copied non-JSON responses.

Need To Check A Conversion?

Use the JSON Validator tool for the direct action. This guide stays focused on the explanation, tradeoffs, mistakes, and reference context behind that task.

A Formatter Must Parse Before It Can Indent

Indentation depends on knowing where arrays, objects, strings, and values begin and end. When syntax is incomplete or contains another language feature, a responsible formatter stops instead of guessing a repair.

Start by checking that the pasted content is actually JSON. Proxy errors, HTML error pages, JavaScript object literals, log prefixes, and copied console output can look similar without being JSON text.

Failure Patterns

Pattern Likely cause Correction
{"a":1,} Trailing comma Remove the final comma
{'a':1} Single quotes Use JSON double quotes
{a:1} Unquoted name Quote the member name
{"a":NaN} Non-JSON number Choose a JSON value or string policy
{} trailing Second value/material Remove or parse the wrapper separately

Invisible And Boundary Problems

  • A leading BOM may be tolerated with a warning, but a BOM inside the text is data or an error.
  • Unescaped control characters cannot appear inside JSON strings.
  • A JSON scalar root such as 42 is valid even when a legacy application expects an object.
  • Deep nesting or very large input may hit an implementation resource limit after syntax is otherwise valid.

Repair Deliberately

Fix the source or apply an explicit repair policy outside the formatter. Automatic quote replacement or comma deletion can change string contents and hide an upstream defect.

After syntax succeeds, validate the destination schema and numeric limits separately.

Related Tools

References

Related Guides In This Category

Browse More Developer Guides

Need the broader support library for this topic? Visit Developer Guides for related references, comparisons, and practical background before returning to the exact tool.

Explore The Full Category

Need another related task? Open Developer Tools for the full tool set, quick-reference examples, and related category paths.