JavaScript has two number types: Number and BigInt.

The most frequently-used number type, Number, is a 64-bit floating point IEEE 754 number.

The largest exact integral value of this type is Number.MAX_SAFE_INTEGER, which is:

  • 253-1, or
  • +/- 9,007,199,254,740,991, or
  • nine quadrillion seven trillion one hundred ninety-nine billion two hundred fifty-four million seven hundred forty thousand nine hundred ninety-one

To put this in perspective: one quadrillion bytes is a petabyte (or one thousand terabytes).

"Safe" in this context refers to the ability to represent integers exactly and to correctly compare them.

From the spec:

Note that all the positive and negative integers whose magnitude is no greater than 253 are representable in the Number type (indeed, the integer 0 has two representations, +0 and -0).

To safely use integers larger than this, you need to use BigInt, which has no upper bound.

Note that the bitwise operators and shift operators operate on 32-bit integers, so in that case, the max safe integer is 231-1, or 2,147,483,647.

const log = console.log
var x = 9007199254740992
var y = -x
log(x == x + 1) // true !
log(y == y - 1) // also true !

// Arithmetic operators work, but bitwise/shifts only operate on int32:
log(x / 2)      // 4503599627370496
log(x >> 1)     // 0
log(x | 1)      // 1


Technical note on the subject of the number 9,007,199,254,740,992: There is an exact IEEE-754 representation of this value, and you can assign and read this value from a variable, so for very carefully chosen applications in the domain of integers less than or equal to this value, you could treat this as a maximum value.

In the general case, you must treat this IEEE-754 value as inexact, because it is ambiguous whether it is encoding the logical value 9,007,199,254,740,992 or 9,007,199,254,740,993.

Answer from Jimmy on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_SAFE_INTEGER
Number.MAX_SAFE_INTEGER - JavaScript | MDN
Number.MAX_SAFE_INTEGER represents ... The largest representable number in JavaScript is actually Number.MAX_VALUE, which is approximately 1.7976931348623157 × 10308....
Top answer
1 of 16
1011

JavaScript has two number types: Number and BigInt.

The most frequently-used number type, Number, is a 64-bit floating point IEEE 754 number.

The largest exact integral value of this type is Number.MAX_SAFE_INTEGER, which is:

  • 253-1, or
  • +/- 9,007,199,254,740,991, or
  • nine quadrillion seven trillion one hundred ninety-nine billion two hundred fifty-four million seven hundred forty thousand nine hundred ninety-one

To put this in perspective: one quadrillion bytes is a petabyte (or one thousand terabytes).

"Safe" in this context refers to the ability to represent integers exactly and to correctly compare them.

From the spec:

Note that all the positive and negative integers whose magnitude is no greater than 253 are representable in the Number type (indeed, the integer 0 has two representations, +0 and -0).

To safely use integers larger than this, you need to use BigInt, which has no upper bound.

Note that the bitwise operators and shift operators operate on 32-bit integers, so in that case, the max safe integer is 231-1, or 2,147,483,647.

const log = console.log
var x = 9007199254740992
var y = -x
log(x == x + 1) // true !
log(y == y - 1) // also true !

// Arithmetic operators work, but bitwise/shifts only operate on int32:
log(x / 2)      // 4503599627370496
log(x >> 1)     // 0
log(x | 1)      // 1


Technical note on the subject of the number 9,007,199,254,740,992: There is an exact IEEE-754 representation of this value, and you can assign and read this value from a variable, so for very carefully chosen applications in the domain of integers less than or equal to this value, you could treat this as a maximum value.

In the general case, you must treat this IEEE-754 value as inexact, because it is ambiguous whether it is encoding the logical value 9,007,199,254,740,992 or 9,007,199,254,740,993.

2 of 16
509

>= ES6:

Number.MIN_SAFE_INTEGER;
Number.MAX_SAFE_INTEGER;

<= ES5

From the reference:

Number.MAX_VALUE;
Number.MIN_VALUE;

console.log('MIN_VALUE', Number.MIN_VALUE);
console.log('MAX_VALUE', Number.MAX_VALUE);

console.log('MIN_SAFE_INTEGER', Number.MIN_SAFE_INTEGER); //ES6
console.log('MAX_SAFE_INTEGER', Number.MAX_SAFE_INTEGER); //ES6

Discussions

Maximum Integer in Js
Fun question! So in JavaScript, every value with the "number" type is represented under the hood with a 64-bit (or "double-precision") floating point number. Floating point numbers represent a value with a combination of fractions and exponents, which allows them to represent a lot of numbers (with varying degrees of precision), but at the end of the day, the value still has to fit within 64-bits somehow. So there are limits. In this case, the highest number a 64-bit float can possibly represent happens to be 1.7976931348623157e+308 (this number is stored in the constant Number.MAX_VALUE should you ever need to reference it). Your value of 1e+309 is larger than that, so the best a 64-bit float can do is call it Infinity. Under the IEEE 754 floating-point standard (which JavaScript uses), there are some special values, like NaN and Infinity. You can basically think of NaN as "something went wrong with this number" and Infinity as "this number is bigger than I can do anything useful with". Both special values sort of infect anything they touch. The result of any math with NaN is NaN. The result of (almost) any math with Infinity is Infinity. console.log(NaN * 2); // NaN console.log(Infinity - 100); // Infinity console.log(Infinity * 0); // NaN Jumping back to those varying degrees of precision, the highest integer you can represent without losing any precision happens to be a good deal smaller than 1e+308. Since everything is actually a float under the hood, you can only get up to 253 - 1 (or 9,007,199,254,740,991) before you can't trust integer math to work right anymore (that number is stored in the constant Number.MAX_SAFE_INTEGER by the way). console.log(9007199254740991 + 10); // 9007199254741000 Now, the good news for anyone who loves big numbers, is that JavaScript recently added a new primitive type, "bigint". You can make a value a BigInt by adding an n to the end, or by calling BigInt on it. const num = 7; // <-- number const big = 7n; // <-- bigint const int = BigInt(7); // <-- bigint There are two big differences between BigInts and vanilla numbers. They are integers, not floating point. This means you can't represent fractions, but you also never lose precision. They are variable-bit. They start as 64-bit, but if the value gets to large, more bits are added. So with BigInt, we can represent big numbers. let x = 10n ** 309n; // e-notation not supported with BigInt console.log(x); // 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n And we can safely do big integer math. console.log(9007199254740991n + 10n); // 9007199254741001n But any decimal places just end up getting dropped. console.log(5n / 2n); // 2n More on reddit.com
🌐 r/learnjavascript
8
43
August 5, 2022
Explanation of safe integers
I recently came across Number.MAX_SAFE_INTEGER and Number.isSafeInteger() I’ve looked online for something to explain WHY these properties of Number are used and what function they would serve. I can’t find anything that really gets across to me. Can someone break this down and explain ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
September 4, 2019
Maximum bigint vs JS Number.MAX_SAFE_INTEGER
Setting article_id to a smaller ... the maximum bigint size fails 9123456890123456 => works 9123456890123456789 => fails ... Beta Was this translation helpful? Give feedback. ... The only way to work around that is to convert any large integers into strings. Otherwise, when your int is sent to the front end, javascript will change ... More on github.com
🌐 github.com
1
1
July 24, 2022
[JavaScript] How come Math.random() with max min doesn't return negative number?
I mean, if you invoke randomRange(22, 1), then the function evaluates to Math.random() * (1 - 22 + 1) + 22 Which simplifies to: Math.random() * -20 + 22 So that will give you some value in the range (2.0, 22.0]. The function floors the result before returning, so you'll get an integer from 2 to 22. (22 is extremely unlikely but technically possible.) More on reddit.com
🌐 r/learnprogramming
3
0
August 17, 2022
People also ask

Q1. What is the number Max_value in JavaScript?
Number.MAX_VALUE is the largest possible number that JavaScript can represent. Its approximate value is 1.79 × 10³⁰⁸.
🌐
intellipaat.com
intellipaat.com › home › blog › javascript highest integer value
JavaScript Highest Integer Value Without Losing Precision
Q2. How big can an int be in JavaScript?
The largest integer value that JavaScript can safely represent without losing precision is the Number.MAX_SAFE_INTEGER, which is 9,007,199,254,740,991 (2^53 – 1).
🌐
intellipaat.com
intellipaat.com › home › blog › javascript highest integer value
JavaScript Highest Integer Value Without Losing Precision
Q5. Is 0 an integer?
Yes, 0 is considered an integer in JavaScript. It is a whole number and falls within the safe integer range.
🌐
intellipaat.com
intellipaat.com › home › blog › javascript highest integer value
JavaScript Highest Integer Value Without Losing Precision
🌐
Programiz
programiz.com › javascript › library › number › max_safe_integer
JavaScript Number.MAX_SAFE_INTEGER
Become a certified JavaScript programmer. Try Programiz PRO! ... The MAX_SAFE_INTEGER constant has a value of 253 - 1 (9007199254740991).
Top answer
1 of 3
75
Fun question! So in JavaScript, every value with the "number" type is represented under the hood with a 64-bit (or "double-precision") floating point number. Floating point numbers represent a value with a combination of fractions and exponents, which allows them to represent a lot of numbers (with varying degrees of precision), but at the end of the day, the value still has to fit within 64-bits somehow. So there are limits. In this case, the highest number a 64-bit float can possibly represent happens to be 1.7976931348623157e+308 (this number is stored in the constant Number.MAX_VALUE should you ever need to reference it). Your value of 1e+309 is larger than that, so the best a 64-bit float can do is call it Infinity. Under the IEEE 754 floating-point standard (which JavaScript uses), there are some special values, like NaN and Infinity. You can basically think of NaN as "something went wrong with this number" and Infinity as "this number is bigger than I can do anything useful with". Both special values sort of infect anything they touch. The result of any math with NaN is NaN. The result of (almost) any math with Infinity is Infinity. console.log(NaN * 2); // NaN console.log(Infinity - 100); // Infinity console.log(Infinity * 0); // NaN Jumping back to those varying degrees of precision, the highest integer you can represent without losing any precision happens to be a good deal smaller than 1e+308. Since everything is actually a float under the hood, you can only get up to 253 - 1 (or 9,007,199,254,740,991) before you can't trust integer math to work right anymore (that number is stored in the constant Number.MAX_SAFE_INTEGER by the way). console.log(9007199254740991 + 10); // 9007199254741000 Now, the good news for anyone who loves big numbers, is that JavaScript recently added a new primitive type, "bigint". You can make a value a BigInt by adding an n to the end, or by calling BigInt on it. const num = 7; // <-- number const big = 7n; // <-- bigint const int = BigInt(7); // <-- bigint There are two big differences between BigInts and vanilla numbers. They are integers, not floating point. This means you can't represent fractions, but you also never lose precision. They are variable-bit. They start as 64-bit, but if the value gets to large, more bits are added. So with BigInt, we can represent big numbers. let x = 10n ** 309n; // e-notation not supported with BigInt console.log(x); // 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n And we can safely do big integer math. console.log(9007199254740991n + 10n); // 9007199254741001n But any decimal places just end up getting dropped. console.log(5n / 2n); // 2n
2 of 3
9
JavaScript uses double-precision floating point values to store numbers. The highest number you can store in this format is 1.7976931348623157e+308 or 2^1024. Anything higher than that is rounded to Infinity, as part of the floating point spec.
🌐
Shareup
shareup.app › blog › there-is-a-maximum-safe-integer-in-javascript
There is a maximum safe integer in JavaScript
The largest integer JavaScript can “safely” represent as a number is 9,007,199,254,740,991 or 2^53 - 1. (This is also available as a static property on Number: Number.MAX_SAFE_INTEGER.)
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-number-max_safe_integer-property
JavaScript Number MAX_SAFE_INTEGER Property - GeeksforGeeks
July 15, 2025 - The JavaScript Number.MAX_SAFE_INTEGER is a constant number that represents the maximum safe integer. This constant has a value of (253 - 1).
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_VALUE
Number.MAX_VALUE - JavaScript | MDN
October 22, 2025 - The Number.MAX_VALUE static data property represents the maximum numeric value representable in JavaScript.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Explanation of safe integers - JavaScript - The freeCodeCamp Forum
September 4, 2019 - I recently came across Number.MAX_SAFE_INTEGER and Number.isSafeInteger() I’ve looked online for something to explain WHY these properties of Number are used and what function they would serve. I can’t find anything t…
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Number › MAX_SAFE_INTEGER
JavaScript Number MAX_SAFE_INTEGER - Maximum Safe Integer | Vultr Docs
December 2, 2024 - In JavaScript, Number.MAX_SAFE_INTEGER represents the highest safe integer value that can be precisely represented in JavaScript.
🌐
Codecademy
codecademy.com › docs › javascript › number methods › .max_safe_integer
JavaScript | Number Methods | .MAX_SAFE_INTEGER | Codecademy
August 1, 2025 - Returns the largest safe integer representable by JavaScript’s Number type. This example demonstrates how .MAX_SAFE_INTEGER defines the upper limit for safe integers in JavaScript:
🌐
W3Schools
w3schools.com › jsref › jsref_max_value.asp
JavaScript MAX_VALUE Property
Number.MAX_VALUE returns the largest number possible in JavaScript. Number.MAX_VALUE has the value of 1.7976931348623157e+308. Numbers larger than MAX_VALUE are represented as Infinity.
🌐
TutorialsPoint
tutorialspoint.com › what-is-javascript-s-highest-integer-value-that-a-number-can-go-to-without-losing-precision
What is JavaScript’s highest integer value that a Number can go to without losing precision?
August 24, 2022 - The number 1.7976931348623157e+308 is the greatest number that the number data type can represent. MAX VALUE. Number.MIN VALUE is the smallest number. <!DOCTYPE html> <html> <title>What is JavaScript's highest integer value that a Number can go to without losing precision?
🌐
Medium
medium.com › @avi2y07111999 › understanding-number-max-safe-integer-and-number-min-safe-integer-in-javascript-b6638d1d05e1
Understanding Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER in JavaScript | by Avinash kumar | Medium
July 31, 2025 - In JavaScript, the Number object ... This constant represents the largest safe integer in JavaScript, with a value of 2^53 - 1, or 9007199254740991....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript | MDN
The Math.max() static method returns the largest of the numbers given as input parameters, or -Infinity if there are no parameters.
🌐
TechOnTheNet
techonthenet.com › js › number_max_safe_integer.php
JavaScript: Number.MAX_SAFE_INTEGER property
In this example, the MAX_SAFE_INTEGER property returned a value of 9007199254740991 which represents the largest safe integer in JavaScript.
🌐
W3Schools
w3schools.com › js › js_numbers.asp
JavaScript Numbers
Integers (numbers without a period or exponent notation) are accurate up to 15 digits. let x = 999999999999999; // x will be 999999999999999 let y = 9999999999999999; // y will be 10000000000000000 Try it Yourself » · The maximum number of ...
🌐
Intellipaat
intellipaat.com › home › blog › javascript highest integer value
JavaScript Highest Integer Value Without Losing Precision
October 17, 2025 - In JavaScript, Number.MAX_VALUE represents the largest possible value that a standard number can hold. However, it’s different from JavaScript MAX_SAFE_INTEGER, which is the largest safe integer value that JavaScript can accurately represent without precision loss.