How to fix “JSON.parse” errors (and avoid them next time)

TL;DR: Make the JSON strict, validate locally, then export/convert (no upload).

If you see errors like “Unexpected token … in JSON at position …”, the input is not valid JSON. This guide explains the most common causes and the fastest way to validate your payload without uploading it anywhere.

Why JSON.parse fails

JSON.parse accepts only strict JSON. That means double quotes for strings, no trailing commas, and no comments. Many “JSON-like” formats (JavaScript objects, config snippets, logs) look similar but aren’t valid JSON, so they fail immediately when parsed.

Use the error position to pinpoint the break

The fastest workflow is to validate first, then fix the exact character that breaks parsing. Most modern browsers include the byte position in the error message. A validator can translate that into a line/column hint, which is much faster than guessing.

Most common causes (real-world)

Here are the top causes:

  • Single quotes: {'a': 1} is JavaScript, not JSON. Use {"a": 1}.
  • Trailing commas: {"a": 1,} is invalid. Remove the last comma.
  • Unquoted keys: {a: 1} is invalid. Keys must be in double quotes.
  • Comments: // comment or /* ... */ are not allowed.
  • Copying from logs: extra characters before/after JSON (timestamps, prefixes) will break parsing.

If the input is supposed to be an array of objects (common for conversions), verify the top-level shape. For example, JSON → CSV expects something like [{"col":"value"}], not a single object {"col":"value"}. Similarly, converters often assume consistent rows/columns.

If you need a safe way to debug sensitive payloads, use a no-upload validator. It runs entirely in your browser — you can validate and fix issues without sending data to a server.

FAQ

Can I validate “confidential JSON” safely? Yes—use a validator that runs locally in your browser. Your payload stays on-device.

Why does JSON.parse complain about a token that “looks normal”? Often the text is not JSON at all (it’s a JavaScript object literal or a log line). Validate syntax first.

Try the no-upload JSON Validator
Privacy & Security
All processing happens locally in your browser. Files are never uploaded.

Practical checklist (fast)

If you’re stuck, use this quick checklist to narrow the problem before you try “random fixes”. Start by validating the input format (syntax first), then confirm shape expectations (array vs object). Convert a small sample, inspect the output, and only then export the full result.

  • Validate: confirm the input is strict JSON (no stray characters).
  • Confirm shape: arrays vs objects (what the converter expects).
  • Test a sample: first 20–50 items are enough to detect parsing issues.
  • Export: copy/download and re-check in the consumer (script/spreadsheet/API).

Local verification snippet

Run a quick local check before export/convert:

const text = input.trim();
const value = JSON.parse(text);
console.log(Array.isArray(value) ? 'array' : typeof value);

Quick fix checklist

  • Reproduce the error on a minimal input.
  • Check type/format and field mapping.
  • Apply the smallest safe fix.
  • Validate on production-like payload.

Next pages to check

Closest crawled pages without impressions yet. Added to speed first-impression conversion.

neighbor csharp go json cannot unmarshal bool into field user id type int troubleshootinneighbor python go json cannot unmarshal string into field payload user type string runbneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type float64 worneighbor csharp go json cannot unmarshal array into field payload items type int workfloneighbor csharp go json cannot unmarshal array into field payload items type int workfloneighbor csharp go json cannot unmarshal array into field payload items type int workfloneighbor csharp go json cannot unmarshal array into field payload user type string checkneighbor csharp go json cannot unmarshal array into field payload user type string checkneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field payload user type string workfneighbor csharp go json cannot unmarshal array into field user createdat type time time neighbor csharp go json cannot unmarshal array into field user createdat type time time