JavaScript BigInt Object
BigInt is a numeric type for whole numbers of any size, written with an n suffix. It is used when numbers are too large to be represented exactly by Number.
Description
A BigInt is a primitive for integers of arbitrary size. Create one by adding n to an integer literal, 123n, or by calling BigInt(value). They are useful for large IDs, precise financial calculations in the smallest unit, and maths beyond Number.MAX_SAFE_INTEGER.
BigInts can't be mixed with numbers in arithmetic: 1n + 1 throws a TypeError, so convert one side explicitly. Division rounds towards zero, there are no decimals, and Math methods don't accept BigInts. typeof returns "bigint", and JSON.stringify() can't serialize them without a custom replacer.
Comparisons between BigInts and numbers work as expected, so 1n < 2 is true and 1n == 1 is true, although 1n === 1 is false because the types differ. Converting a large BigInt to a number with Number() can lose precision. BigInt.asIntN() and BigInt.asUintN() wrap a value to a fixed number of bits, which is useful when working with 64-bit binary data.
Syntax
123n
BigInt(value)Example
Browser Support
The following information will show you the current browser support for the BigInt object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





