If they're meant to be separate values, try this:
var values = "554,20".split(",")
var v1 = parseFloat(values[0])
var v2 = parseFloat(values[1])
If they're meant to be a single value (like in French, where one-half is written 0,5)
var value = parseFloat("554,20".replace(",", "."));
Answer from Jesse Rusak on Stack OverflowMozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Data_structures
JavaScript data types and data structures - JavaScript | MDN
It is also the only value in JavaScript that is not equal to itself. Although a number is conceptually a "mathematical value" and is always implicitly floating-point-encoded, JavaScript provides bitwise operators. When applying bitwise operators, the number is first converted to a 32-bit integer.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › parseFloat
parseFloat() - JavaScript | MDN
The parseFloat() function parses a string argument and returns a floating point number.
Converting a string to a float in Javascript?
+"3.4" => 3.4 More on reddit.com
Convert string to Float
Hello Everyone! I didn’t find such topic. So I decide to to set up a topic. I couldn’t find at script manual the function to convert string to float. I tried to use the Python function a = "52525238,27337273,83495772" float(a) or int(a) but it didn’t work. Can somebody help me with this? More on forum.universal-robots.com
What is the fastest way to convert string to float out of these 13 methods?
Well most of those won't cast to a float as they're bitwise operations. But in general, use parseFloat. Don't prematurely optimise. More on reddit.com
Library/function that will tidy up weird JS float values without converting to string in between?
If precision is important, then just use integers for everything and convert to floats only at the end for the UI; if you want to round to a specific precision then just multiply your floats into ints, round, and then divide back down again: function round(number, precision = 1){ return Math.round( number * Math.pow(10, precision) ) / Math.pow(10, precision); } // with int rounding round(0.2 + 0.1); // 0.3 // without int rounding // 0.2 + 0.1 = 0.30000000000000004 More on reddit.com
Videos
03:06
How to convert a STRING to FLOAT/INT in JavaScript. - YouTube
04:51
How to Use parseFloat in JavaScript | Convert Strings to Decimal ...
01:36
How to Convert String into Float in JavaScript - YouTube
06:41
✅ Convert String to Number in JavaScript | JavaScript ParseInt ...
07:40
How to Convert Strings to Numbers & Numbers to Strings in JavaScript ...
03:27
How to Convert String into Number in JavaScript — (4 Easy Methods) ...
Top answer 1 of 9
445
If they're meant to be separate values, try this:
var values = "554,20".split(",")
var v1 = parseFloat(values[0])
var v2 = parseFloat(values[1])
If they're meant to be a single value (like in French, where one-half is written 0,5)
var value = parseFloat("554,20".replace(",", "."));
2 of 9
64
Have you ever tried to do this? :p
var str = '3.8';ie
alert( +(str) + 0.2 );
+(string) will cast string into float.
Handy!
So in order to solve your problem, you can do something like this:
var floatValue = +(str.replace(/,/,'.'));
W3Schools
w3schools.com › jsref › jsref_parsefloat.asp
JavaScript parseFloat() Method
The parseFloat() method parses a value as a string and returns the first number. If the first character cannot be converted, NaN is returned. Leading and trailing spaces are ignored.
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript string to float
JavaScript String to Float | Two Methods to Convert String to Float
March 27, 2023 - This method uses the JavaScript Type Conversion function to convert the string type to float.
Call +917738666252
Address Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Udemy
blog.udemy.com › home › javascript parsefloat: a simple way to convert strings into floating point numbers
JavaScript parseFloat: a simple way to convert strings into floating point numbers - Udemy Blog
December 4, 2019 - Here the web page prompts the user to enter a string in the text box and uses parseFloat to parse it and returns the result as a floating number. var num1 = prompt(“enter a number”) var answer = parseFloat(num1) Alert(“the number you entered is:” + answer) Now, let me explain the code. var in JavaScript means a variable.
TutorialKart
tutorialkart.com › javascript › javascript-convert-string-to-float
How to convert String to Float in JavaScript?
September 23, 2021 - To convert a string to float in JavaScript, call parseFloat() function and pass the string as argument to it.
TypeScript
typescriptlang.org › docs › handbook › 2 › everyday-types.html
TypeScript: Documentation - Everyday Types
string represents string values like "Hello, world" number is for numbers like 42. JavaScript does not have a special runtime value for integers, so there’s no equivalent to int or float - everything is simply number
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-parse-float-with-two-decimal-places-in-javascript
How to Parse Float with Two Decimal Places in JavaScript? - GeeksforGeeks
JavaScript provides an inbuilt parseFloat() method to parse a string and returns a floating-point number. Below are the approaches to parse float to two decimal places in JavaScript: ... The parseFloat() method converts a string to a floating-point ...
Published July 23, 2025
Reddit
reddit.com › r/javascript › converting a string to a float in javascript?
r/javascript on Reddit: Converting a string to a float in Javascript?
March 27, 2015 -
I can't use parseFloat(). I am so far doing the obvious by checking each character, but I feel there has to be a more elegant way! My function needs to act exactly the same as parseFloat() does. Can anyone help?
DigitalOcean
digitalocean.com › community › tutorials › python-convert-string-to-float
How to Convert String to Float in Python: Complete Guide with Examples | DigitalOcean
July 10, 2025 - Learn how to convert strings to floats in Python using float(). Includes syntax, examples, error handling tips, and real-world use cases for data parsing.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › parseFloat
Number.parseFloat() - JavaScript | MDN
The Number.parseFloat() static method parses an argument and returns a floating point number. If a number cannot be parsed from the argument, it returns NaN.