invalid character ']' after top-level value: Go JSON.Unmarshal — causes and fixes

TL;DR: Validate locally, fix the first real error, validate again (no upload).

Troubleshoot invalid character ']' after top-level value quickly and validate JSON locally (no upload).

What the error means

invalid character ']' after top-level value means the parser expected valid JSON but encountered a character/token that cannot appear there. In practice, it usually means the input is not JSON (or not strict JSON), or it is incomplete.

Most common real-world causes

  • The input is not strict JSON (single quotes, comments, trailing commas).
  • The response is truncated (missing closing } / ] / ").
  • The response contains a prefix/suffix (logs, banners, debug output).
  • The payload has invalid escapes or control characters in strings.
  • You are parsing the wrong thing (already-parsed object, HTML, CSV, etc).

Fast debugging steps

  • Validate the JSON as-is to get an exact error location.
  • Check the first and last 50 characters for truncation and prefixes.
  • Fix one issue at a time and re-validate after each change.

Code example (go)

body := bytes.TrimSpace(rawBody)
if len(body) == 0 {
    return fmt.Errorf("empty JSON input")
}
if body[0] == '<' {
    return fmt.Errorf("got HTML instead of JSON")
}
if err := json.Unmarshal(body, &v); err != nil {
    return err
}

Fix without uploading data

If the JSON contains sensitive data, validate and fix it locally. No Upload Tools runs 100% in your browser.

Workflow: validate -> fix the first error -> validate again -> export/convert.

FAQ

Does the exact token matter? Yes. The token often hints at the root cause: < is usually HTML, u is often undefined, and / often points to comments.

Should I just regex-fix JSON? Avoid blind regex edits. Validate after each change so you know what you fixed and what broke.

Privacy & Security
All processing happens locally in your browser. Files are never uploaded.

Next pages to check

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

neighbor csharp csharp newtonsoft additional text after finished reading json content p neighbor csharp csharp newtonsoft error converting false system datetime value workflowsneighbor csharp csharp newtonsoft error converting false system guid value workflows entneighbor csharp csharp newtonsoft error converting null system datetime value troubleshoneighbor csharp csharp newtonsoft error converting true system int64 value workflows apineighbor csharp csharp newtonsoft error converting true system int64 value workflows webneighbor csharp csharp newtonsoft error converting true system uri value workflows data neighbor csharp csharp newtonsoft error converting true system uri value workflows enterneighbor csharp csharp stj could not be converted system timespan value workflows webhooneighbor csharp csharp stj could not be converted system double createdat workflows webhneighbor csharp csharp stj could not be converted system int32 items 0 id checklists ananeighbor csharp csharp stj could not be converted system int32 items 0 id checklists edgneighbor csharp csharp stj could not be converted system int32 items 0 id workflows enteneighbor csharp csharp stj could not be converted system int32 user id checklists analytneighbor csharp go json cannot unmarshal bool into field user id type int troubleshootinneighbor csharp csharp newtonsoft error converting null system datetime value checklistsneighbor csharp csharp newtonsoft error converting null system datetime value workflows neighbor csharp csharp newtonsoft error converting null system datetime value workflows

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.