JavaScript Number MAX_SAFE_INTEGER Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Static property

What You’ll Learn

Number.MAX_SAFE_INTEGER is a static data property on Number (same API as MDN Number.MAX_SAFE_INTEGER). It is the largest integer a JavaScript Number can represent exactly253 − 1 (9007199254740991). Beyond it, use BigInt. This tutorial covers its value, the famous +1 === +2 trap, how it relates to EPSILON and MAX_VALUE, five examples, and try-it labs.

01

Kind

Static property

02

Value

253−1

03

Means

Exact integers

04

Beyond

Use BigInt

05

Writable

No

06

Baseline

Everywhere

Introduction

JavaScript Numbers are IEEE-754 doubles. They can be enormous ((MAX_VALUE), but they cannot label every integer exactly once the magnitude grows. The 52-bit fraction (plus an implicit leading 1) gives 53 bits of integer precision.

Number.MAX_SAFE_INTEGER is 253 − 1 — the top of the range where consecutive integers are still distinct and comparable. Past that point, some integers are skipped.

💡
Static Property

Static properties belong to Number itself. Always write Number.MAX_SAFE_INTEGER. There is no (5).MAX_SAFE_INTEGER, and you do not call it like a function.

This page is part of JavaScript Number Properties. Related tools include Number.isSafeInteger(), Number.EPSILON, and Number.MAX_VALUE.

Understanding the MAX_SAFE_INTEGER Property

“Safe” means two things: the integer can be stored exactly, and integer comparisons / increments behave as you expect. Outside −MAX_SAFE_INTEGER … MAX_SAFE_INTEGER, that guarantee breaks.

  • It is a constant number, not a method.
  • Value: 9007199254740991 (253 − 1).
  • Pair with Number.MIN_SAFE_INTEGER for the negative bound (same magnitude).
  • For larger exact integers, prefer BigInt.

📝 Syntax

General form of the static property Number.MAX_SAFE_INTEGER:

JavaScript
Number.MAX_SAFE_INTEGER

Value

9007199254740991 (253 − 1).

Property attributes

AttributeValue
Writablefalse
Enumerablefalse
Configurablefalse

Common patterns

JavaScript
Number.MAX_SAFE_INTEGER;                 // 9007199254740991
Number.MAX_SAFE_INTEGER === 2 ** 53 - 1; // true

Number.isSafeInteger(Number.MAX_SAFE_INTEGER);     // true
Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 1); // false

// Prefer BigInt past the safe range:
9007199254740993n;  // exact

⚡ Quick Reference

GoalCode
Largest exact integerNumber.MAX_SAFE_INTEGER
Smallest exact integerNumber.MIN_SAFE_INTEGER
Test a candidateNumber.isSafeInteger(n)
Larger exact intsBigInt / 123n
Largest finite floatNumber.MAX_VALUE (not exact ints)
Link to EPSILONMAX_SAFE_INTEGER * EPSILON ≈ 2

🔍 At a Glance

Four facts to remember about Number.MAX_SAFE_INTEGER.

Kind
static

Property on Number

Value
2**53-1

9007199254740991

Safe
exact

Integer precision holds

Mutable
no

Read-only constant

📋 MAX_SAFE_INTEGER vs MAX_VALUE vs BigInt

MAX_SAFE_INTEGERMAX_VALUEBigInt
Approx. size~9.0e15~1.8e308Arbitrary
Exact integers?Yes (up to bound)No (sparse)Yes
Typenumbernumberbigint
Use forIDs / counts in rangeMagnitude ceilingHuge exact ints

Examples Gallery

Examples follow MDN Number.MAX_SAFE_INTEGER patterns. Use View Output or Try It Yourself for each case.

📚 Getting Started

Read the constant and see why “safe” matters.

Example 1 — Read Number.MAX_SAFE_INTEGER

Print the largest exact integer Number.

JavaScript
Number.MAX_SAFE_INTEGER;
// 9007199254740991
Try It Yourself

How It Works

Same as 2 ** 53 - 1. Prefer the named constant in readable code.

Example 2 — MDN +1 === +2 Trap

Past the safe limit, consecutive integers are no longer distinct.

JavaScript
const x = Number.MAX_SAFE_INTEGER + 1;
const y = Number.MAX_SAFE_INTEGER + 2;

Number.MAX_SAFE_INTEGER;  // 9007199254740991
x;                        // 9007199254740992
x === y;                  // true  (!)
Try It Yourself

How It Works

Both x and y round to the same float. Math says they differ; IEEE-754 cannot tell them apart.

📈 Practical Patterns

Checks, mantissa links, and magnitude vs precision.

Example 3 — Pair with isSafeInteger()

Test whether a value is still inside the exact-integer window.

JavaScript
Number.isSafeInteger(Number.MAX_SAFE_INTEGER);     // true
Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 1); // false
Try It Yourself

How It Works

See the full isSafeInteger() tutorial for coercion rules and edge cases.

Example 4 — Relationship with EPSILON

Both constants come from the 53-bit significand.

JavaScript
Number.MAX_SAFE_INTEGER * Number.EPSILON;
// 1.9999999999999998  (very close to 2)
Try It Yourself

How It Works

EPSILON is 2−52; MAX_SAFE_INTEGER is 253 − 1. Their product is almost 2 — an MDN teaching link between the two constants.

Example 5 — vs MAX_VALUE

Huge finite floats are not the same as exact integers.

JavaScript
Number.MAX_VALUE > Number.MAX_SAFE_INTEGER;  // true
Number.isSafeInteger(Number.MAX_VALUE);      // false
Try It Yourself

How It Works

MAX_VALUE answers “how large?” MAX_SAFE_INTEGER answers “how exact for integers?”

🚀 Common Use Cases

  • ID / counter bounds — keep database keys and counters inside the safe range.
  • JSON numbers — JSON has no BigInt; stay ≤ MAX_SAFE_INTEGER or use strings.
  • ValidationNumber.isSafeInteger(n) before trusting integer math.
  • Teaching floats — show why large integers need BigInt.
  • Not a magnitude ceiling — use MAX_VALUE for overflow-to-Infinity.
  • Timestamps / snowflakes — many 64-bit IDs exceed the safe Number range.

🧠 How Safe Integers Work

1

53-bit significand

Doubles store about 53 bits of precision for the fraction.

Bits
2

Exact up to 253−1

Every integer in that window has a unique Number encoding.

Safe
3

Gaps appear above

Some integers cannot be represented; neighbors collapse together.

Trap
4

Switch strategy

Stay in range, or move to BigInt / string IDs.

📝 Notes

  • This is a static property — use Number.MAX_SAFE_INTEGER only.
  • Do not write Number.MAX_SAFE_INTEGER() — it is not a function.
  • “Safe” = exact + correctly comparable integers.
  • Do not confuse with MAX_VALUE.
  • Negative twin: Number.MIN_SAFE_INTEGER (-(253 − 1)).
  • For larger exact integers, use BigInt.

Browser & Runtime Support

Number.MAX_SAFE_INTEGER is Baseline Widely available — part of ES2015 and supported in every modern browser and Node.js.

Baseline · Widely available

Number.MAX_SAFE_INTEGER

Safe for production everywhere. Use it as the named ceiling for exact Number integers.

100% Universal support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Number.MAX_SAFE_INTEGER Excellent

Bottom line: Stay within MAX_SAFE_INTEGER for exact Number integers. Use BigInt past that. Use MAX_VALUE only for magnitude / Infinity overflow.

Conclusion

Number.MAX_SAFE_INTEGER is the static constant for the largest integer a JavaScript Number can represent exactly. Past that point, prefer BigInt (or strings) when every integer must stay distinct.

Continue with isSafeInteger(), MAX_VALUE, EPSILON, or the Number properties hub.

💡 Best Practices

✅ Do

  • Read Number.MAX_SAFE_INTEGER on the constructor
  • Validate with Number.isSafeInteger(n)
  • Use BigInt for integers beyond the safe range
  • Keep JSON numeric IDs inside the safe window (or use strings)
  • Remember the negative bound MIN_SAFE_INTEGER

❌ Don’t

  • Write (5).MAX_SAFE_INTEGER or call it as a function
  • Assume MAX_VALUE integers are exact
  • Increment past the safe limit and trust ===
  • Store 64-bit snowflake IDs as plain Numbers
  • Mix BigInt and Number in the same arithmetic without converting

Key Takeaways

Knowledge Unlocked

Five things to remember about Number.MAX_SAFE_INTEGER

Static ceiling for exact Number integers.

5
Core concepts
📝 02

Value

2**53-1

Constant
03

Trap

+1 === +2

Pitfall
n 04

Beyond

BigInt

Next
05

Mutable

no

Readonly

❓ Frequently Asked Questions

Number.MAX_SAFE_INTEGER is the largest integer JavaScript can represent exactly as a Number — 2^53 - 1, which is 9007199254740991. Above that, integer spacing is no longer 1.
Yes. Read it on Number itself: Number.MAX_SAFE_INTEGER. There is no (5).MAX_SAFE_INTEGER on number instances, and it is not a method.
Safe means integers can be represented exactly and compared correctly. Past MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 is true — which is mathematically wrong.
MAX_SAFE_INTEGER (~9e15) is the largest exact integer. MAX_VALUE (~1.8e308) is the largest finite float magnitude. Huge floats above the safe integer range are not precise integers.
Use BigInt for integers beyond the safe range. You can also check candidates with Number.isSafeInteger(n).
It is Baseline Widely available (ES2015) and supported in every modern browser and Node.js.
Did you know?

Many social / database “snowflake” IDs are 64-bit integers — larger than Number.MAX_SAFE_INTEGER. Storing them as plain JSON numbers can silently corrupt the last digits. Teams often keep them as strings or BigInt instead.

More Number Properties

Return to the hub for static Number constants.

Number properties hub →

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.

8 people found this page helpful