It's not possible to natively deal with a 21-digit precision number in JavaScript.

JavaScript only has one kind of number: "number", which is a IEEE-754 Double Precision ("double") value. As such, parseFloat in JavaScript is the equivalent of a "parse double" in other languages.

However, a number/"double" only provides 16 significant digits (decimal) of precision and so reading in a number with 21-digits will lose the 5 least significant digits1.

For more precision (or accuracy) a "big number" library must be used;

  • What is the standard solution in JavaScript for handling big numbers (BigNum)?

1 Information can be lost when encoding as an IEEE "double", which cannot encode all decimal values exactly, but that's another question..

Answer from user2864740 on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-a-currency-string-to-a-double-value-with-jquery-or-javascript
How to convert a currency string to a double value with jQuery or Javascript? - GeeksforGeeks
July 12, 2025 - This approach directly employs a regular expression to match numeric and decimal characters in the currency string. It then extracts these characters, joins them to form a numeric string, and converts it to a double value using parseFloat(). JavaScript ·
🌐
Delft Stack
delftstack.com › home › howto › javascript › javascript parsedouble
JavaScript parseDouble | Delft Stack
March 11, 2025 - In the world of JavaScript, you might notice a peculiar absence: the parseDouble function. While other programming languages often provide a straightforward way to convert strings or integers into double-precision floating-point numbers, JavaScript opts for the parseFloat method instead.
🌐
W3Schools
w3schools.com › jsref › jsref_parsefloat.asp
JavaScript parseFloat() Method
The parseFloat() method parses a value as a string and returns the first number.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › parseInt
parseInt() - JavaScript | MDN
The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN. If not NaN, the return value will be the integer that is the first argument taken as a number in the specified radix. (For example, a radix of 10 converts from a decimal number, ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-program-for-double-to-string-conversion
JavaScript Program for Double to String Conversion | GeeksforGeeks
February 23, 2024 - Utilize the toString() method available for JavaScript number objects to convert the double to a string.
🌐
Flexiple
flexiple.com › javascript › parsefloat-javascript
parseFloat JavaScript: Syntax and Examples - Flexiple
If parseFloat encounters a character other than a plus(+), minus (-), numerals (0–9), decimal (.), or exponent (e or E), it returns the value up to that character, ignoring the invalid character and characters following it.
Find elsewhere
🌐
Reddit
reddit.com › r/learnjavascript › json.parse twice?
r/learnjavascript on Reddit: JSON.parse twice?
August 7, 2019 -

I am working through freecodecamp's walk through of building a full stack react app using firebase and ran into a strange issue.

I was able to post my request body successfully, but since it was an array, I used JSON.parse before adding it to firebase.

When I checked my DB, it came in as a string.

I couldn't figure it out until I saw on SO a suggestion to parse it twice, and that worked.

Can someone help me understand why the first parse produced just a string instead of the array and it required a second parse call?

🌐
GeeksforGeeks
geeksforgeeks.org › 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.
Published   January 9, 2025
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › parse
JSON.parse() - JavaScript | MDN
JSON strings must be delimited by double (not single) quotes: js · JSON.parse("{'foo': 1}"); // SyntaxError: Unexpected token ' in JSON at position 1 JSON.parse("'string'"); // SyntaxError: Unexpected token ' in JSON at position 0 · If you are writing JSON inside a JavaScript string literal, you should either use single quotes to delimit the JavaScript string literal, or escape the double quotes that delimit the JSON string: js ·
🌐
Fauna documentation
docs.fauna.com › fauna › current › reference › fql-api › string › parsedouble
string.parseDouble() - Fauna Docs
Convert a String to a Double. parseDouble() => Number | Null · Converts the calling String to a numeric Double. The calling String isn’t changed. Leading and trailing whitespace are allowed.
🌐
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.
🌐
CopyProgramming
copyprogramming.com › howto › parse-double-javascript
Parse double javascript - Javascript
April 29, 2023 - Parse double javascript, JavaScript Conversion Techniques: Converting Between Double and Float Precision, Using parseInt to Parse a Double: A Guide
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › parseFloat
parseFloat() - JavaScript | MDN
Anecdotally, because the string NaN itself is invalid syntax as accepted by parseFloat(), passing "NaN" returns NaN as well. ... Infinity values are returned when the number is outside the double-precision 64-bit IEEE 754-2019 format range:
🌐
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.
🌐
Vultr Docs
docs.vultr.com › javascript › global › parseFloat
JavaScript parseFloat() - Parse String to Float | Vultr Docs
November 6, 2024 - The parseFloat() function in JavaScript is a invaluable tool for transforming string data into float numbers, significantly aiding in calculations and data processing. It efficiently handles a variety of string formats including those with ...