Favorites

JavaScript Number.isSafeInteger() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Number.isSafeInteger()
JavaScript Number Static methodThis method is supported by all modern browsers.
Updated 28th November 2026

The Number.isSafeInteger() static method checks whether a value is an integer small enough to be stored exactly.

Description

The Number.isSafeInteger() static method returns true if the value is an integer between -(253 - 1) and 253 - 1. Within that range, every integer is stored exactly; beyond it, adjacent integers can't be told apart. Use BigInt for larger values.

A safe integer is one that can be represented exactly and compared correctly. Integers outside the safe range may round to a neighbouring value, so a large ID received as a number could silently point to the wrong record. That's why many APIs send large IDs as strings.

The bounds are available as Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER. Values that aren't numbers, or aren't integers, return false. Like other static members of Number, it is called on the Number constructor itself, not on individual number values.

Syntax

Number.isSafeInteger(value)

Parameters

  • valueThe value to check.

Return Value

true if the value is an integer that can be represented exactly, otherwise false.

Example

console.log(Number.isSafeInteger(2 ** 53 - 1));
console.log(Number.isSafeInteger(2 ** 53));
console.log(2 ** 53 === 2 ** 53 + 1);

Browser Support

The following information will show you the current browser support for the Number.isSafeInteger() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee