How to Convert a JavaScript BigInt Value to a Number?

You can convert a bigint to a number by simply using the Number wrapper object like so:

// ES10+
const MAX_SAFE_INTEGER = 9007199254740991n;

console.log(Number(MAX_SAFE_INTEGER)); // 9007199254740991

Please be aware that the precision of a BigInt value may be lost when it is coerced to a Number value (and back).

Hope you found this post useful. It was published . Please show your love and support by sharing this post.