BigInt
In one line
BigInt is a numeric type for integers of arbitrary size, beyond the safe limit of the Number type.
In simple words
BigInt is a primitive type for whole numbers larger than Number can safely represent. JavaScript Numbers are 64-bit floats, which can only exactly represent integers up to 2^53 - 1 (about 9 quadrillion). Beyond that, precision is lost. BigInt has no such limit — it can represent arbitrarily large integers.
You create a BigInt by appending n to an integer literal (123n) or by calling BigInt(value). BigInts support +, -, *, /, %, **, and bitwise operators, but they cannot be mixed with Numbers — you must convert explicitly. Division truncates toward zero (no fractions).
Use BigInt for cryptography, exact large-number arithmetic, 64-bit IDs, and any calculation where Number precision loss would be a bug. Most JSON APIs use numbers within the safe range, so you do not need BigInt for everyday math.
Example
const huge = 2n ** 100n; // 2^100, far beyond Number's safe range
console.log(huge); // 1267650600228229401496703205376n
const a = 9007199254740993n; // 2^53 + 1, not safe as Number
console.log(a + 1n); // 9007199254740994n — exact
// Cannot mix with Number: 1n + 1 throws TypeError
console.log(BigInt(10) + 5n); // 15n2n ** 100n computes an exact 31-digit integer. The n suffix creates a BigInt. Mixing with Number throws — convert explicitly.
Related terms
Related Resources
Related Lessons
- Numbers
Learn BigInt.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.