JavaScript Number.parseFloat() Method
The Number.parseFloat() static method reads a decimal number from the start of a string. It is identical to the global parseFloat().
Description
The Number.parseFloat() static method parses a string and returns a floating point number, ignoring anything after the number. It is exactly the same function as the global parseFloat(), provided on Number to group number helpers together.
It reads digits, a decimal point and an exponent from the start of the string, ignoring leading white space, and stops at the first character that doesn't fit, so Number.parseFloat('1.5em') is 1.5. If no number can be read at all, the result is NaN.
Unlike Number(), it doesn't treat an empty string as 0, and it accepts trailing text. Choose Number() when the whole string must be a valid number, such as form input, and parseFloat() when extracting a number from text like CSS values.
Syntax
Number.parseFloat(string)Parameters
- stringThe value to parse.
Return Value
A floating point number, or NaN.
Example
Browser Support
The following information will show you the current browser support for the Number.parseFloat() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





