ConvertCSV

Common JSON Errors and How to Fix Them

By Convert CSV Editorial TeamLast updated August 1, 2026

Fix the most common JSON errors: trailing commas, bad quotes, encoding issues, and shape mismatches. Diagnose fast with clear examples.

Two Buckets: Syntax and Shape

Almost every "broken JSON" ticket falls into one of two categories. Syntax errors mean the parser cannot even load the document. Shape errors mean it loaded but does not match what your code expects.

The fixes are different, so diagnose the bucket first.

Syntax Errors

These are the ones that make JSON.parse throw.

Trailing commas

JSON does not allow trailing commas in arrays or objects, even though JavaScript does.

// Bad
{
  "a": 1,
  "b": 2,
}

// Good
{
  "a": 1,
  "b": 2
}

Single quotes

JSON strings and keys must use double quotes.

// Bad
{ 'name': 'Ada' }

// Good
{ "name": "Ada" }

Unquoted keys

Object keys are always strings in JSON.

// Bad
{ name: "Ada" }

// Good
{ "name": "Ada" }

Comments

Standard JSON does not allow comments. Use JSON5 or JSONC if you need them, but do not send them over the wire.

Unescaped newlines and quotes

Escape special characters inside string values.

// Bad
{ "note": "Line one
Line two" }

// Good
{ "note": "Line one\nLine two" }

Duplicate keys

Not strictly a parse error in every implementation, but most parsers keep only the last value, silently losing data.

Encoding Errors

Bytes that look like garbage are almost always an encoding mismatch.

  • UTF-8 is the only interoperable choice for JSON.
  • Do not embed a BOM in JSON files—many parsers reject them.
  • Escape non-ASCII characters (\u00e9) or serve as UTF-8 with the correct Content-Type header.
  • "é" showing as "é" means UTF-8 was decoded as Windows-1252.

Shape Errors

The JSON parsed, but something downstream broke.

SymptomLikely causeFix
undefined field accessMissing keyHandle optional or update sender
Numbers turning to InfinityOverflow in JSSend big IDs as strings
"true" is truthy but wrongString instead of booleanFix producer type
Array became objectOne-item vs many API splitAlways send arrays
Dates parse to wrong dayTimezone mismatchISO 8601 with timezone

Errors From CSV → JSON

When JSON is generated from CSV, expect these quirks.

  • Boolean columns become strings ("true", "false") unless the converter is told to cast.
  • Empty cells become empty strings, not null—decide the convention.
  • Numeric IDs may be cast to numbers, losing leading zeros.
  • Dates in local format get preserved as strings; convert to ISO 8601 in a follow-up step.

Diagnostic Workflow

Work through this list top to bottom.

  • Run jq . file.json (or JSON.parse) to catch parse errors.
  • Check encoding with file file.json.
  • Validate shape against a JSON Schema.
  • Diff against a known-good sample.
  • For CSV sources, re-run the conversion with typed columns.

Real-World Examples

The most common tickets we all see.

"Unexpected token } in JSON"

Almost always a trailing comma. Some editors auto-add it when reformatting.

"NaN in id"

A big numeric ID overflowed JavaScript. Fix on the producer side by shipping IDs as strings.

"Mojibake in customer names"

Non-ASCII characters served as Windows-1252 instead of UTF-8. Set Content-Type: application/json; charset=utf-8 and re-encode the file.

Common Mistakes

Habits that create more errors than they fix.

  • Ignoring parser errors by wrapping in try/catch and moving on.
  • Hand-editing minified JSON and forgetting a comma.
  • Trusting an online "fixer" instead of understanding the error.
  • Using JSON5 in production and being surprised strict parsers reject it.
  • Skipping schema validation because "the client is trusted".

Best Practices

The habits that keep JSON healthy.

  • Lint JSON in CI.
  • Validate against a schema at every trust boundary.
  • Standardize on UTF-8 without a BOM.
  • IDs as strings; dates as ISO 8601.
  • Fail loudly on unknown fields.

Why Use Convert CSV Online?

When you suspect the CSV source is the problem, Convert CSV Online is free, browser-based, and needs no account for everyday conversions. Preview the CSV in the Online CSV Editor, fix the offending column, then regenerate JSON. Client-side workflows work on Windows, macOS, and Linux browsers.

Fix at the source

A single cleanup upstream removes an entire class of JSON errors.

Conclusion

Almost every JSON bug is a trailing comma, an encoding mismatch, or a shape you did not expect. Learn the three, then move on to validating with a schema.

FAQ

What is the most common JSON error?

Trailing commas after the last element of an object or array. JSON does not allow them, even though JavaScript does.

How do I fix Unexpected token in JSON?

Look at the character position from the error and check for trailing commas, single quotes, unquoted keys, or unescaped newlines.

Why do accented characters look wrong?

The file is not UTF-8 or is being decoded as another code page. Re-save as UTF-8 and set Content-Type: application/json; charset=utf-8.

Why do my big IDs turn into wrong numbers?

JavaScript numbers lose precision above 2^53. Send big IDs as JSON strings to preserve them.

Can JSON have comments?

Standard JSON cannot. JSON5 and JSONC add comments, but strict parsers will reject those files.

How do I catch JSON errors before shipping?

Run a JSON linter or jq . in CI and validate structured payloads against a JSON Schema.

References

Convert your CSV in the browser

Preview, clean, and convert CSV files free with Convert CSV Online—no installation and no account required for everyday conversions.