JavaScript Number.MAX_SAFE_INTEGER Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Number.MAX_SAFE_INTEGER is the largest integer a JavaScript Number can represent exactly — 253 - 1 (9007199254740991). Above that, float rounding skips integers. It is a static property (ES2015), not a method.

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use Number.MAX_SAFE_INTEGER. Start with this line.

JavaScript
Number.MAX_SAFE_INTEGER
CallWhat it does
Number.MAX_SAFE_INTEGERPrimary signature.

Built into JavaScript. Read Number.MAX_SAFE_INTEGER on the Number constructor — no import required.

Library declarations
JavaScript
Number.MAX_SAFE_INTEGER

Parameters

ParameterDescription
BigIntOptional. Exact integers outside the safe range

Return Value

Return ValueDescription
*The current value of Number.MAX_SAFE_INTEGER.

JavaScript Examples

Example 1 — Read Number.MAX_SAFE_INTEGER

Print the constant and confirm it equals 2 ** 53 - 1.

JavaScript
console.log(Number.MAX_SAFE_INTEGER);
console.log(Number.MAX_SAFE_INTEGER === 2 ** 53 - 1);
Try It Yourself

How It Works

  1. Static access. Read Number.MAX_SAFE_INTEGER on the constructor.
  2. Exact value. Engines print 9007199254740991.
  3. Definition. That number is exactly 2 ** 53 - 1 in IEEE-754 doubles.
  4. Read-only. It is a non-writable constant in modern engines.

Example 2 — Precision Loss Past the Limit

Adding 1 or 2 past the max safe integer produces the same float.

JavaScript
const max = Number.MAX_SAFE_INTEGER;

console.log(max + 1);
console.log(max + 2);
console.log(max + 1 === max + 2);  // true — not safe!
Try It Yourself

How It Works

  1. At the edge. max is still exact.
  2. Next even float. max + 1 lands on 9007199254740992.
  3. Odd skipped. max + 2 cannot store a distinct odd integer — same bits.
  4. Dangerous equality. === says they match even though the math differs.

Example 3 — Guard with Number.isSafeInteger

Check values at the boundary before trusting integer math.

JavaScript
const max = Number.MAX_SAFE_INTEGER;

console.log(Number.isSafeInteger(max));      // true
console.log(Number.isSafeInteger(max + 1));  // false
console.log(Number.isSafeInteger(9007199254740991)); // true
Try It Yourself

How It Works

  1. At the limit. max itself is a safe integer → true.
  2. One past. max + 1 is outside the safe range → false.
  3. Literal form. The decimal literal 9007199254740991 is the same safe value.
  4. Use as a gate. Reject or convert to BigInt when the check fails.

Browser & Runtime Support

Number.MAX_SAFE_INTEGER is part of ES2015 and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · ES2015

Number.MAX_SAFE_INTEGER

Supported in Chrome, Firefox, Safari, Edge, and Node.js for years. Safe for modern apps without a polyfill.

98% Modern browser 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: Use Number.MAX_SAFE_INTEGER freely in modern JavaScript. Older engines without it can use the literal Math.pow(2, 53) - 1 as a fallback.

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, consecutive integers are no longer all representable.
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. Check candidates with Number.isSafeInteger(n) before relying on Number arithmetic.
It is Baseline Widely available (ES2015) and supported in every modern browser and Node.js.

Next: MIN_SAFE_INTEGER

Learn the smallest exact integer JavaScript can represent as a Number.

MIN_SAFE_INTEGER 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.

11 people found this page helpful