JavaScript BigInt Methods

Beginner
4 min read
Updated: Nov 2026
5 method guides
Method index

About This Index

This page is the JavaScript BigInt Methods index for the tutorial track. Each row links to a full guide with syntax, three runnable examples, browser notes, and FAQs.

Learn what a BigInt is and why JavaScript needs it on /js/bigint. Use this page when you need one specific method, such as toString(), toLocaleString(), or BigInt.asIntN().

Two kinds of methods.

Static methods are called on BigInt itself: BigInt.asIntN(8, 255n). Instance methods are called on a BigInt value: (255n).toString(16). Writing (255n).asIntN gives undefined, because static methods do not live on the values.

How to Call a BigInt Method

Static methods take the number of bits first and the BigInt second. Instance methods are called with a dot on the value:

JavaScript
// Static methods: call them on BigInt itself
BigInt.asIntN(8, 255n);                 // -1n
BigInt.asUintN(8, -1n);                 // 255n

// Instance methods: call them on a BigInt value
(255n).toString(16);                    // "ff"
(1234567n).toLocaleString("en-US");     // "1,234,567"
Object(5n).valueOf();                   // 5n

The comments show what each line gives back. A trailing n marks a BigInt result; text in quotes is a string.

JavaScript BigInt Methods Table

All method guides in this JavaScript tutorial series (5 tutorials), grouped by how you call them.

Static methods

2 methods

Called on BigInt itself. They fit a BigInt into a fixed number of bits, the way a 64-bit or 8-bit integer would store it.

MethodDescriptionTutorial
BigInt.asIntN()Wrap a BigInt into a signed integer of a given bit width, so it can come out negative.Open
BigInt.asUintN()Wrap a BigInt into an unsigned integer of a given bit width, so it is never negative.Open

Instance methods

3 methods

Called on a BigInt value such as 255n. They turn the BigInt into text or give back the plain BigInt value.

MethodDescriptionTutorial
toString()Turn a BigInt into a string of digits, in base 10 or any base from 2 to 36.Open
toLocaleString()Format a BigInt for people: separators, currency, or compact notation for a chosen locale.Open
valueOf()Get the plain (primitive) BigInt value, for example out of an Object(5n) wrapper.Open

Frequently Asked Questions

Five: two static methods, BigInt.asIntN() and BigInt.asUintN(), and three instance methods, toString(), toLocaleString(), and valueOf().
Start with toString(). You need it to print a BigInt, to change its base, and to put it into JSON. Then learn toLocaleString() for readable output.
Static methods are called on BigInt itself, like BigInt.asIntN(8, 255n). Instance methods are called on a value, like (255n).toString(16).
The comparator must return a Number, but a - b is a BigInt when a and b are BigInts, so sort() throws a TypeError. Return -1, 1, or 0 instead: (a, b) => (a < b ? -1 : a > b ? 1 : 0).
No. Math.max(1n, 2n), Math.sqrt(16n), and the other Math functions throw a TypeError for BigInts. Use comparison operators and BigInt arithmetic, or convert small values with Number().

Start with BigInt.asIntN()

See how a big number wraps into a signed 8-bit or 64-bit integer, and why 255n becomes -1n.

asIntN() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful