like this:

var foo = 45;
var bar = '' + foo;

Actually, even though I typically do it like this for simple convenience, over 1,000s of iterations it appears for raw speed there is an advantage for .toString()

See Performance tests here (not by me, but found when I went to write my own): http://jsben.ch/#/ghQYR

Fastest based on the JSPerf test above: str = num.toString();

It should be noted that the difference in speed is not overly significant when you consider that it can do the conversion any way 1 Million times in 0.1 seconds.

Update: The speed seems to differ greatly by browser. In Chrome num + '' seems to be fastest based on this test http://jsben.ch/#/ghQYR

Update 2: Again based on my test above it should be noted that Firefox 20.0.1 executes the .toString() about 100 times slower than the '' + num sample.

Answer from scunliffe on Stack Overflow
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ parseInt
parseInt() - JavaScript | MDN
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, 8 converts from octal, 16 from hexadecimal, and so on.) The radix argument is converted to a number. If it's unprovided, or if the value becomes 0, NaN or Infinity (undefined is coerced to NaN), JavaScript assumes the following: If the input string, with leading whitespace and possible +/- signs removed, begins with 0x or 0X (a zero, followed by lowercase or uppercase X), radix is assumed to be 16 and the rest of the string is parsed as a hexadecimal number.
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_parseint.asp
W3Schools.com
cssText getPropertyPriority() ... years"); parseInt("He was 40"); Try it Yourself ยป ยท The parseInt method parses a value as a string and returns the first integer....
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Number โ€บ toString
Number.prototype.toString() - JavaScript | MDN
The toString() method of Number values returns a string representing this number value. function hexColor(c) { if (c < 256) { return Math.abs(c).toString(16); } return 0; } console.log(hexColor(233)); // Expected output: "e9" console.log(hexColor("11")); // Expected output: "b" ... An integer ...
๐ŸŒ
Flexiple
flexiple.com โ€บ javascript โ€บ convert-int-to-string
JavaScript Number to String โ€“ How to Use toString to Convert an Int into a String - Flexiple
Use the toString() method to convert an Int into a string in JavaScript. JavaScript developers often need to convert data types, especially when managing user inputs or displaying numbers as part of a user interface.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ javascript-number-to-string-how-to-use-tostring-to-convert-an-int-into-a-string
JavaScript Number to String โ€“ How to Use toString to Convert an Int into a String
March 22, 2021 - The toString() method is a built-in method of the JavaScript Number object that allows you to convert any number type value into its string type representation. How to Use the toString Method in JavaScript To use the toString() method, you simply ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Number โ€บ parseInt
Number.parseInt() - JavaScript | MDN
The Number.parseInt() static method parses a string argument and returns an integer of the specified radix or base. function roughScale(x, base) { const parsed = Number.parseInt(x, base); if (Number.isNaN(parsed)) { return 0; } return parsed * 100; } console.log(roughScale(" 0xF", 16)); // ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ convert-a-number-to-a-string-in-javascript
Convert a Number to a String in JavaScript - GeeksforGeeks
July 23, 2025 - This method belongs to the Number.Prototype object. It takes an integer or a floating-point number and converts it into a string type.
Find elsewhere
๐ŸŒ
Mozilla
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Guide โ€บ Numbers_and_strings
Numbers and strings - JavaScript | MDN
JavaScript's String type is used to represent textual data. It is a set of "elements" of 16-bit unsigned integer values (UTF-16 code units). Each element in the String occupies a position in the String. The first element is at index 0, the next at index 1, and so on. The length of a String is the number of elements in it. You can create strings using string literals or string objects. You can declare strings in source code using either single or double quotes: js ยท
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ javascript โ€บ standard-library โ€บ Number โ€บ toString
JavaScript Number toString() - Convert to String | Vultr Docs
September 27, 2024 - Apply the toString() method to convert it to a string. ... This code snippet demonstrates converting the decimal number 123 into the string "123" using toString().
๐ŸŒ
CoreUI
coreui.io โ€บ answers โ€บ how-to-convert-a-number-to-a-string-in-javascript
How to convert a number to a string in JavaScript ยท CoreUI
September 27, 2025 - This method is reliable, widely supported, and offers additional control over number representation when needed. Use the toString() method to convert a number to its string representation.
๐ŸŒ
Medium
medium.com โ€บ @rwijayabandu โ€บ how-to-convert-number-to-string-in-javascript-7c08e221e5b0
How to convert number to string in JavaScript? | by Ravithamara | Medium
August 18, 2024 - Concatenate the empty string with the number, it will convert the whole number to a string. One of the easiest ways to convert any integer or floating-point number into a string.
๐ŸŒ
HostingAdvice
hostingadvice.com โ€บ home โ€บ how-to
JavaScript: int to string
March 24, 2023 - Here are some examples of the toString() method being used on numbers: var x = 10; // integer number var y = 7.950; // floating point number var z = 1.21eโ€“6; // floating point number in a scientific notation var inf = Number.POSITIVE_INFINITY; ...
๐ŸŒ
DEV Community
dev.to โ€บ sanchithasr โ€บ 5-ways-to-convert-number-to-string-3fhd
5 ways to convert a number to string in JavaScript - DEV Community
August 19, 2021 - Adding empty string to the number value will convert the data to string is one of the simplest way to do the job. It is also considered to be faster than the above two when it comes to performance. myNumber = 22 myString = '' + myNumber // expected result: '22' fltNumber = 25.54 fltString = '' + fltNumber // expected result: '25.54' With the introduction of template strings in ES6, injecting a number inside a String is a valid way of parsing an Integer or Float data type.
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ javascript โ€บ programs โ€บ int-to-string
Convert Int to String in JavaScript (7 Programs)
January 22, 2026 - Learn 7 easy programs to convert an Integer to a String in JavaScript. Step-by-step examples for beginners with examples, output, and explanation. Read now!
Top answer
1 of 16
3114

The simplest way would be to use the native Number function:

var x = Number("1000")

If that doesn't work for you, then there are the parseInt, unary plus, parseFloat with floor, and Math.round methods.

parseInt()

var x = parseInt("1000", 10); // You want to use radix 10
    // So you get a decimal number even with a leading 0 and an old browser ([IE8, Firefox 20, Chrome 22 and older][1])

Unary plus

If your string is already in the form of an integer:

var x = +"1000";

floor()

If your string is or might be a float and you want an integer:

var x = Math.floor("1000.01"); // floor() automatically converts string to number

Or, if you're going to be using Math.floor several times:

var floor = Math.floor;
var x = floor("1000.01");

parseFloat()

If you're the type who forgets to put the radix in when you call parseInt, you can use parseFloat and round it however you like. Here I use floor.

var floor = Math.floor;
var x = floor(parseFloat("1000.01"));

round()

Interestingly, Math.round (like Math.floor) will do a string to number conversion, so if you want the number rounded (or if you have an integer in the string), this is a great way, maybe my favorite:

var round = Math.round;
var x = round("1000"); // Equivalent to round("1000", 0)
2 of 16
306

Try parseInt function:

var number = parseInt("10");

But there is a problem. If you try to convert "010" using parseInt function, it detects as octal number, and will return number 8. So, you need to specify a radix (from 2 to 36). In this case base 10.

parseInt(string, radix)

Example:

var result = parseInt("010", 10) == 10; // Returns true

var result = parseInt("010") == 10; // Returns false

Note that parseInt ignores bad data after parsing anything valid.
This guid will parse as 51:

var result = parseInt('51e3daf6-b521-446a-9f5b-a1bb4d8bac36', 10) == 51; // Returns true
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-convert-numbers-to-string-in-javascript
How to convert numbers to string in JavaScript
We can use the String() constructor to convert a number to a string. When null or undefined is passed, then null and undefined Strings will be returned (respectively). ... By adding an empty string, the number will internally be converted to String.
๐ŸŒ
SitePoint
sitepoint.com โ€บ blog โ€บ javascript โ€บ quick tip: how to convert a number to a string in javascript
Quick Tip: How to Convert a Number to a String in JavaScript โ€” SitePoint
November 7, 2024 - See the Pen String Interpolation in JavaScript by SitePoint (@SitePoint) on CodePen. The second approach is string concatenation. You can convert a number to a string using the + operator.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ javascript-convert-number-to-string
JavaScript Convert Number to String
March 11, 2019 - There are some built-in methods in JavaScript that provide conversion from an number data type to a String, which only differ in performance and readability. ... The .toString() method that belongs to the Number.prototype object, takes an integer or floating point number and converts it into ...