Skip to main content

Convert STRING to NUMBER, Free

Files convert instantly in your browser. 100% private, any file size, no account needed.

100% private No signup Unlimited size No upload

How to convert STRING to NUMBER

In programming and data processing, values often arrive as text strings even when they represent numbers. A CSV file column might contain '42.5' as a string. A form field might return '1000' as text. API responses frequently serialize numbers as strings. Converting a string to a number means parsing the text and producing the appropriate numeric type, handling cases like leading zeros, commas in thousands separators, currency symbols, and whitespace.

This converter parses the string you enter and shows the numeric interpretation, including the data type (integer, float, NaN) and any parsing edge cases. It runs instantly in JavaScript. Useful for debugging data pipelines, understanding how different programming languages handle string-to-number conversion, and cleaning data before processing.

Enter the string value

Type or paste the string you want to interpret as a number. Try values like '42', '3.14', '1,000', '$50', '0x1F' (hex), '0b1010' (binary), or ' 99 ' (with whitespace).

See the parsed result

The converter shows the numeric value using standard JavaScript parsing rules. Leading/trailing whitespace is ignored. Commas and currency symbols cause NaN (not a number). Hex strings with '0x' prefix parse as integers.

Check the data type

The result is labeled as integer (no decimal component), float (has decimal), or NaN (the string could not be parsed as a number). Strings like 'abc' and '1,000' produce NaN.

Test edge cases

Try '01' (may be parsed as 1, not octal in modern JS), 'Infinity', '-Infinity', '', and 'null' to understand how the parser handles boundary inputs in your target environment.

Frequently asked questions

Why does '1,000' return NaN when converting to a number?

JavaScript's parseFloat and Number() functions do not recognize commas as thousands separators. '1,000' is not a valid numeric literal, so the parser returns NaN. To handle comma-formatted numbers, strip commas before converting: '1,000'.replace(/,/g, '') converts to '1000', which parses correctly.

What is the difference between parseInt and parseFloat?

parseInt('3.7') returns 3 (truncates the decimal). parseFloat('3.7') returns 3.7. parseInt can also accept a base argument: parseInt('1F', 16) = 31. Use parseFloat for any value that may have a decimal component.

Why does parseInt('08') return 8 in modern JavaScript but sometimes returned 0 in old code?

Old JavaScript (pre-ES5) treated strings with a leading zero as octal. '08' is not valid octal (8 is not an octal digit), so it returned 0. Modern JavaScript ignores the leading zero in parseInt unless the '0x' or '0o' prefix is explicitly used.

What happens when you convert an empty string to a number?

Number('') returns 0 in JavaScript. parseFloat('') returns NaN. This inconsistency is a common source of bugs in form validation code.