Get to know MDN better
The JavaScript exception "x can't be converted to BigInt" occurs when attempting to convert a Symbol, null, or undefined value to a BigInt, or if an operation expecting a BigInt parameter receives a number.
When using the BigInt() function to convert a value to a BigInt, the value would first be converted to a primitive. Then, if it's not one of BigInt, string, number, and boolean, the error is thrown.
Some operations, like BigInt.asIntN, require the parameter to be a BigInt. Passing in a number in this case will also throw this error.
Note: Simply coercing the value to a string or number using String() or Number() before passing it to BigInt() is usually not sufficient to avoid all errors. If the string is not a valid integer number string, a SyntaxError is thrown; if the number is not an integer (most notably, NaN), a RangeError is thrown. If the range of input is unknown, properly validate it before using BigInt().
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.