Favorites

JavaScript Number.parseInt() Method

☕
Enjoying this site?

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

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

The Number.parseInt() static method reads an integer from the start of a string, in a given base. It is identical to the global parseInt().

Description

The Number.parseInt() static method parses a string and returns an integer in the given radix. It's the same function as the global parseInt(). Always pass the radix, usually 10.

Using Number.parseInt() instead of the global function makes it clear that the code is working with numbers, and some style guides prefer it for that reason. It ignores leading white space, stops at the first invalid character, and returns NaN if no digits can be read.

Decimals are cut off rather than rounded, and numbers written in exponential notation are read only up to the e, so Number.parseInt('1e3') is 1. Use Math.round() or Math.trunc() on an actual number when you want to drop decimals.

Syntax

Number.parseInt(string)
Number.parseInt(string, radix)

Parameters

  • stringThe value to parse.
  • radixOptional. The base, from 2 to 36.

Return Value

An integer, or NaN.

Example

console.log(Number.parseInt('42px', 10));
console.log(Number.parseInt('1010', 2));
console.log(Number.parseInt === parseInt);

Browser Support

The following information will show you the current browser support for the Number.parseInt() 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