[JavaScript] Parse an integer from a string with parseInt()

Created on November 30, 2026

You can use parseInt() to read an integer from a string. The first argument is the string, and the second is its radix. Use 10 for decimal input.

console.log(parseInt('111', 10));
111

parseInt() stops when it reaches a character that cannot be part of the integer. If it cannot read an integer at the start, it returns NaN.

JavaScript