You can use toFixed() to do that

var twoPlacedFloat = parseFloat(yourString).toFixed(2)
Answer from Mahesh Velaga on Stack Overflow
Discussions

parsing string to decimal doesn't return decimals JavaScript - Stack Overflow
I'm new to writing JavaScript, I'm trying to convert two values from a string to a number, however, I have tried to doing the following approaches but none seem to work. Example: const num = pars... More on stackoverflow.com
🌐 stackoverflow.com
alternative to JSON.parse() for maintaining decimal precision?
I'm fairly sure this is a JavaScript thing, not a JSON thing or a JSON parser thing. If you just open up your dev tools and try assigning some long decimals to variables, you'll notice they get rounded or exponentised too. If you just want to display all the 0s, you want to use toFixed() , which will give you a string with up to 20 decimal places. More on reddit.com
🌐 r/javascript
7
3
December 21, 2017
convert a JavaScript string variable to decimal/money - Stack Overflow
How can we convert a JavaScript string variable to decimal? ... Save this answer. ... Show activity on this post. Yes -- parseFloat. More on stackoverflow.com
🌐 stackoverflow.com
math - parseDecimal in JavaScript? - Stack Overflow
I have some JS calculations going on. Since floating point arithmetic often uses close approximations to numbers instead of exact values, if you round these floating point number to fixed precisio... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › Recrosoftware › js-parse-decimal
GitHub - Recrosoftware/js-parse-decimal: ParseDecimal utility · GitHub
This library provides a simple parseDecimal function that parses the given numerical input (number, bigint, string) into a DecimalDefinition object that describes the given number.
Author: Recrosoftware
🌐
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
The custom parseFloat method converts a number to a string, slices it to retain only the desired decimal places, and then converts it back to a number.
Published: July 23, 2025
🌐
CodeSweetly
codesweetly.com › javascript-parseint-method
parseInt() in JavaScript – How to Convert String to Decimal | CodeSweetly
The parseInt() global method parses and converts its string argument from its radix state to a decimal integer.
🌐
Attacomsian
attacomsian.com › blog › javascript-parse-float-two-decimal-places
Parse float with 2 decimal places in JavaScript
November 27, 2022 - Use the parseFloat() method to parse the string to a float point number. Use the toFixed() method to format the floating point number to 2 decimal places.
🌐
W3Schools
w3schools.com › jsref › jsref_parsefloat.asp
JavaScript parseFloat() Method
The parseFloat() method parses a value as a string and returns the first number.
Find elsewhere
🌐
Copahost
copahost.com › home › javascript parsefloat: examples and variations of this function
Javascript parseFloat: Examples and variations of this function - Copahost
July 16, 2023 - The parseFloat method in javascript can also be used with decimals. We can pass a string containing a decimal number and get the corresponding floating-point number.
🌐
YouTube
youtube.com › watch
How to Format Numbers with toFixed() and parseFloat() in JavaScript | Round and Convert Values in JS - YouTube
Want to format numbers in JavaScript to 2 decimal places or convert strings to numbers? In this beginner-friendly tutorial, you’ll learn how to use toFixed()...
Published: July 6, 2025
🌐
npm
npmjs.com › package › parse-decimal-number
parse-decimal-number - npm
August 16, 2017 - Returns a float representation of string or NaN if string is not a parseable number. Use the optional options parameter to specify the thousands and decimal point characters.
      » npm install parse-decimal-number
    
Published: Aug 16, 2017
Version: 1.0.0
🌐
Mikemcl
mikemcl.github.io › decimal.js
decimal.js API
A new Decimal constructor is created by calling the clone method of an already existing Decimal constructor. ... A legitimate value is an integer or float, including ±0, or is ±Infinity, or NaN. The number of digits of value is not limited, except by JavaScript's maximum array size and, in practice, the processing time required.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-parse-float-with-two-decimal-places-in-javascript
How to parse float with two decimal places in JavaScript?
Javascript · PHP · Economics ... · Computer Glossary · Who is Who · To parse float with two decimal places, use the concept of toFixed(2)....
🌐
Sabe
sabe.io › blog › javascript-parse-float-two-decimal-places
How to Parse Float to 2 Decimal Places in JavaScript - Sabe.io
August 23, 2022 - JAVASCRIPTconst string = "123.456"; const parseToTwoDecimalPlaces = (string) => { const fixedString = parseFloat(string).toFixed(2); return parseFloat(fixedString); } const number = parseToTwoDecimalPlaces(string); console.log(number); ...
🌐
YouTube
youtube.com › watch
How to Use parseFloat in JavaScript | Convert Strings to Decimal Numbers with Real Code Examples - YouTube
Need to work with decimal numbers in your JavaScript code? In this beginner-friendly tutorial, you’ll learn how to use parseFloat() in JavaScript to convert ...
Published: July 14, 2025
🌐
DEV Community
dev.to › himanshudevgupta › 7-ways-to-convert-a-string-to-number-in-javascript-35pd
7 ways to convert a String to Number in JavaScript - DEV Community
February 21, 2023 - If you parse the decimal number, it will be rounded off to the nearest integer value and that value is converted to string. One might need to use parseFloat() method for literal conversion. myString = '129' console.log(parseInt(myString)) // ...
🌐
Medium
medium.com › @maxheadway › the-differences-between-number-and-parsefloat-in-javascript-8ee74b961ed4
The differences between Number() and parseFloat() in ...
February 19, 2023 - The parseFloat Function The parseFloat function is used to convert a string to a floating-point number. It parses the string argument and returns a floating-point number. If the string contains any characters other than numeric digits and decimal ...