Formatter Validator Minifier Escape / Unescape JSON ↔ String JSON ↔ YAML JSON → CSV NDJSON / JSON Lines JSON → Types JSON ↔ XML JSON Diff JSON Patch Canonicalize (RFC 8785) Schema Validator Schema Generator JSONPath Tester JWT Decoder JSON Errors Schemas More Tools
JSONTools / JSON errors / 'g' is invalid after a single JSON value. Expected
System.Text.Json JsonDocument · .NET 8.0.30

'g' is invalid after a single JSON value. Expected end of data. LineNumber: L | BytePositionInLine: C.

This message comes from System.Text.Json JsonDocument on .NET 8.0.30. In this registry it is produced by 1 distinct mistake. Positions in the real message vary with your input; the causes do not.

What produces this message

Trailing characters after a JSON document

Input
{"a": 1} garbage

Exact message: 'g' is invalid after a single JSON value. Expected end of data. LineNumber: 0 | BytePositionInLine: 9.

Fix: Trim everything after the final closing brace, and check whatever produced the file for stray writes to stdout.

What other parsers say about the same input

If a colleague reports a different message for what looks like the same file, this is why.

Parser Message for the same inputs
CPython json.loadsExtra data: line L column C (char N)
GsonUse JsonReader.setLenient(true) to accept malformed JSON at line L column C path $…
Gson JsonParser (lenient off)Use JsonReader.setLenient(true) to accept malformed JSON at line L column C path $…
JSON5JSON5: invalid character 'g' at 1:10
JSON::PPgarbage after JSON object, at character offset N (before "…")
JavaScriptCore JSON.parseJSON Parse error: Unable to parse JSON string
Newtonsoft.Json JsonConvertAdditional text encountered after finished reading JSON content: g. Path '', line L, position N.
Newtonsoft.Json JsonTextReaderAdditional text encountered after finished reading JSON content: g. Path '', line L, position N.
Ruby JSON.parseunexpected token at '…'
SpiderMonkey JSON.parseJSON.parse: unexpected non-whitespace character after JSON data at line L column C of the JSON data
System.Text.Json Deserialize'g' is invalid after a single JSON value. Expected end of data. Path: $ | LineNumber: L | BytePositionInLine: C.
V8 JSON.parseUnexpected non-whitespace character after JSON at position N (line L column C)
encoding/json Unmarshalinvalid character 'g' after top-level value
hjsonSyntax error, found trailing characters at line L,9
json-bigintSyntax error
json_decodeSyntax error
orjsonunexpected content after document: line L column C (char N)
serde_json::from_strtrailing characters at line L column C
ujsonTrailing data

← All JSON parser errors

Standards this registry is checked against

Only standards bodies and peer-reviewed venues are cited. Error strings on this site are observed by executing each parser; the standards above define what the parser is reacting to.