You can use toFixed() to do that

var twoPlacedFloat = parseFloat(yourString).toFixed(2)
Answer from Mahesh Velaga on Stack Overflow
๐ŸŒ
Attacomsian
attacomsian.com โ€บ blog โ€บ javascript-parse-float-two-decimal-places
Parse float with 2 decimal places in JavaScript
November 27, 2022 - Learn how to use the toFixed() method to parse a float with 2 decimal places in JavaScript.
๐ŸŒ
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
Example 1: In this example the parseFloat converts strings to floating-point numbers. toFixed(2) rounds the number to 2 decimal places, returning a string.
Published ย  July 23, 2025
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-parse-float-with-two-decimal-places-in-javascript
How to parse float with two decimal places in JavaScript?
To parse float with two decimal places, use the concept of toFixed(2). Following is the code โˆ’ ยท var price = 178932.89; var tax = 7.9; var totalPrice = price*tax; console.log("The actual value="+totalPrice); var gettingTwoPlacedValues = parseFloat(totalPrice).toFixed(2); console.log("After ...
๐ŸŒ
Linux Hint
linuxhint.com โ€บ parse-float-with-two-decimal-places-javascript
How to Parse Float With Two Decimal Places in JavaScript?
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
SourceFreeze
sourcefreeze.com โ€บ home โ€บ parse float with 2 decimals in javascript
Parse Float with 2 decimals in javascript - Source Freeze
March 21, 2023 - In this tutorial, we will more about how to parse the float with 2 decimals in JavaScript.
Find elsewhere
๐ŸŒ
EyeHunts
tutorial.eyehunts.com โ€บ home โ€บ javascript string to float 2 decimal | example code
JavaScript string to float 2 decimal | Example code
June 29, 2022 - Use toFixed() function to parse the string to float 2 decimal in JavaScript. And for performance use math round 100 times as fast as parse...
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ javascript-format-number-to-two-decimal-places
Format a number to 2 Decimal places in JavaScript | bobbyhadz
This is because the binary floating-point format cannot accurately represent numbers like 0.1 or 0.2. The code gets rounded to the nearest number, resulting in a rounding error. The toFixed method returns a string. If you need the result to be of type number, call the parseFloat() method on ...
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_parsefloat.asp
JavaScript parseFloat() Method
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-parse-float-with-two-decimal-places-in-typescript
How to Parse Float with Two Decimal Places in TypeScript ? - GeeksforGeeks
April 28, 2025 - Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Number โ€บ toFixed
Number.prototype.toFixed() - JavaScript | MDN
The toFixed() method of Number values returns a string representing this number using fixed-point notation with the specified number of decimal places.
๐ŸŒ
MSR
rajamsr.com โ€บ home โ€บ javascript parsefloat(): how to avoid common mistakes
JavaScript ParseFloat(): How to Avoid Common Mistakes | MSR - Web Dev Simplified
January 28, 2024 - Learn best practices and limitations of the JavaScript parseFloat() function. Convert strings to floating-point numbers accurately.
๐ŸŒ
Three.js
discourse.threejs.org โ€บ discussion
๐Ÿ™Š Change floating-point to 2 decimal places? - Discussion - three.js forum
Before I go down this rabbit hole further. If you could share your wisdom/experience. Iโ€™m assuming with certain large floating-point numbers is a known problem and CAN NOT be converted to 2 decimal places. As these large numbers appear to be an error, it is the way things work with my current ...
Published ย  July 24, 2018
๐ŸŒ
Squash
squash.io โ€บ how-to-round-to-2-decimal-places-in-javascript
How To Round To 2 Decimal Places In Javascript
Learn how to round numbers in JavaScript to at most 2 decimal places with simple code examples.
๐ŸŒ
Copahost
copahost.com โ€บ home โ€บ javascript parsefloat: examples and variations of this function
Javascript parseFloat: Examples and variations of this function - Copahost
July 16, 2023 - We have to pass a number in the toFixed method and the resulting integer will have that many numbers of digits after the decimal. The following example shows how to use the toFixed method with the parseFloat. ... In the above code, we use a toFixed method and passed a value of 2 in it.