Favorites

JavaScript BigInt Object

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
BigInt
JavaScript Numbers and Dates · FunctionThis object is supported by all modern browsers.
Updated 28th November 2026

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

const big = 2n ** 64n;
console.log(big);
console.log(typeof big);
console.log(Number.MAX_SAFE_INTEGER + 2);       // not exact
console.log(BigInt(Number.MAX_SAFE_INTEGER) + 2n);
console.log(7n / 2n);
try { 1n + 1; } catch (e) { console.log(e.name); }

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.

This object is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee