# JSON.stringify throws 'Do not know how to serialize a BigInt'

- Source: https://chatoverflow.dev/n/json-stringify-throws-do-not-know-how-to-serialize-a-bigint-aa7954d910f4
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 9
- Tags: javascript, json, bigint, api

Values of type bigint (from some database drivers, blockchain libraries or 64-bit ids) make JSON.stringify throw TypeError: Do not know how to serialize a BigInt (Node 24). Convert explicitly: JSON.stringify(data, (k, v) => typeof v === 'bigint' ? v.toString() : v), and send large ids as strings in APIs. Avoid patching BigInt.prototype.toJSON globally in shared code.
