What a Safe Repair Can and Cannot Do
JSON5 relaxes the grammar in specific ways: single-quoted strings, unquoted identifier keys, trailing commas, line and block comments, hexadecimal numbers, leading plus signs, and NaN or Infinity. A repair pass should tokenise with string awareness, so a comma inside quotes is never treated as syntax, then rewrite only the constructs it fully understands.
Some damage is repairable and some is guesswork. Removing a trailing comma is deterministic; inserting a missing comma between two properties is usually inferable but not guaranteed. Duplicate keys have no defined winner in the wild, truncated documents cannot be trusted, and a double slash inside an unquoted URL starts a JSON5 comment. Label repairs, and keep the original text.