Number.parseInt(string, radix) reads a string and returns an integer. Optional radix (2–36) sets the numeric base. It skips leading whitespace, stops at the first invalid digit for that base, and is the same function as global parseInt.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call Number.parseInt. Start with this line.
JavaScript
Number.parseInt(string, radix)
Call
What it does
Number.parseInt(string, radix)
Primary signature.
Number.parseInt(...)
Call with the arguments your case needs.
Built into JavaScript. Call Number.parseInt(...) on the Number constructor — no import required.
Library declarations
JavaScript
Number.parseInt(string, radix)
Parameters
Parameter
Description
string
Required. Value to parse (coerced to string)
Return Value
Return Value
Description
*
Integer number, or NaN
JavaScript Examples
Example 1 — Decimal Parsing and Trailing Junk
Always pass radix 10. Junk after digits is ignored.
0x prefix. With radix 16, a leading 0x is allowed and skipped.
Base 36. Digits can use 0–9 and a–z; Z is 35.
Example 3 — Failed Parse Returns NaN
If no valid digit starts the string for that radix, the result is NaN.
JavaScript
console.log(Number.parseInt("hello", 10)); // NaN
console.log(Number.parseInt("", 10)); // NaN
console.log(Number.isNaN(Number.parseInt("hello", 10))); // true
console.log(Number.parseInt("15.9", 10)); // 15 — not NaN
Partial success."15.9" still yields 15 — not a failure. Use parseFloat if you need the fraction.
Compatibility
Browser & Runtime Support
Number.parseInt() is part of ES2015 (as a Number static) and is Baseline Widely available. Global parseInt has existed much longer.
✓ Baseline · ES2015
Number.parseInt()
Supported in Chrome, Firefox, Safari, Edge, and Node.js. Safe for modern apps; global parseInt works even in very old environments.
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.parseIntExcellent
Bottom line: Use Number.parseInt(s, radix) for new code. Always pass an explicit radix.
Frequently Asked Questions
Number.parseInt(string, radix) reads a string and returns an integer. Optional radix sets the base from 2 to 36. Example: Number.parseInt("42", 10) is 42; Number.parseInt("ff", 16) is 255.
Yes. Call it on Number itself: Number.parseInt(s, radix). It is the same function as the global parseInt — Number.parseInt === parseInt is true.
radix is an optional integer from 2 to 36 for the numeric base. Use 2 for binary, 10 for decimal, 16 for hexadecimal. Always pass 10 for everyday decimal parsing so the base is never ambiguous.
Parsing stops at the first character that is not valid for the chosen radix. Number.parseInt("42px", 10) returns 42. If nothing valid is found at the start, the result is NaN.
Number("42px") is NaN because the whole string must be a valid number. Number.parseInt("42px", 10) is 42 because it reads a leading integer prefix.
It is Baseline Widely available (ES2015) and supported in every modern browser and Node.js.