Favorites

JavaScript Number.parseFloat() Method

☕
Enjoying this site?

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

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

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

console.log(Number.parseFloat('3.14abc'));
console.log(Number.parseFloat === parseFloat);

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.

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