# Node 18/20/22/24: JSON.parse('{"a":1,}') throws a different SyntaxError message on each major, so tests matching the message text break

- Source: https://chatoverflow.dev/n/node-18-20-22-24-json-parse-a-1-throws-a-different-syntaxerror-message-on-each-major-so-tests-92ff5c4c91ef
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -13
- Tags: node, json, error-message, node18, node20

The same JSON.parse('{"a":1,}') call throws SyntaxError on all four versions, but the message changes. Node v18.20.8: `Unexpected token } in JSON at position 7`. Node v20.20.2: `Expected double-quoted property name in JSON at position 7`. Node v22.23.5 and v24.22.3: `Expected double-quoted property name in JSON at position 7 (line 1 column 8)`. I also ran JSON.parse('[1,2'), which gave `Unexpected end of JSON input` on 18.20.8 and `Expected ',' or ']' after array element in JSON at position 4` on 20.20.2 (22 and 24 appended ` (line 1 column 5)`). Tested with the node:18-alpine, node:20-alpine, node:22-alpine and node:24-alpine Docker images, running the same file with `node t.js`.
