Number.isSafeInteger(value) returns true only when value is an integer in the safe rangeNumber.MIN_SAFE_INTEGER … Number.MAX_SAFE_INTEGER (±(253 − 1)). It is a static method (ES2015) and does not coerce types.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call Number.isSafeInteger. Start with this line.
JavaScript
Number.isSafeInteger(value)
Call
What it does
Number.isSafeInteger(value)
Primary signature.
Number.isSafeInteger(...)
Call with the arguments your case needs.
Built into JavaScript. Call Number.isSafeInteger(...) on the Number constructor — no import required.
Library declarations
JavaScript
Number.isSafeInteger(value)
Parameters
Parameter
Description
value
Required. Any value to test
Return Value
Return Value
Description
*
true or false
JavaScript Examples
Example 1 — Safe Integers Pass
Everyday integers and the max/min safe limits all pass.
Floats fail.3.1 has a fractional part → not an integer.
No coercion."3" is a string → false.
Parse first.Number("3") yields a safe integer → true.
Specials fail.NaN and Infinity are never safe integers.
Compatibility
Browser & Runtime Support
Number.isSafeInteger() is part of ES2015 and is Baseline Widely available in modern browsers and Node.js.
✓ Baseline · ES2015
Number.isSafeInteger()
Supported in Chrome, Firefox, Safari, Edge, and Node.js for years. Safe for modern apps without a polyfill.
98%Modern browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Number.isSafeIntegerExcellent
Bottom line: Use Number.isSafeInteger for new code. Fall back to a polyfill only if you must support very old environments.
Frequently Asked Questions
Number.isSafeInteger(value) returns true only when value is an integer in the safe range from Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER (±(2^53 − 1)). Example: Number.isSafeInteger(3) is true; Number.isSafeInteger(2 ** 53) is false.
Yes. Call it on Number itself: Number.isSafeInteger(x). Do not call it on a number instance like (5).isSafeInteger() — that is not the Number API.
A safe integer can be exactly represented in IEEE-754 double precision, and nearby integers do not round to the same floating-point value. The range is −9007199254740991 to 9007199254740991.
Number.isInteger(2 ** 53) is true, but Number.isSafeInteger(2 ** 53) is false. Every safe integer is an integer, but not every integer Number value is safe.
No. Number.isSafeInteger("3") is false. Parse first if you need to accept text: Number.isSafeInteger(Number("3")).
It is Baseline Widely available (ES2015) and supported in every modern browser and Node.js.