VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-string-tostring-method/

⇱ JavaScript String toString() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript String toString() Method

Last Updated : 11 Jul, 2025

The toString() method in JavaScript converts a string object to a string primitive. It returns a string representing the specified object. This method is automatically called when a string object needs to be defined as a text value or concatenated with another string. The toString() method also converts a number to a string.

Syntax:

string.toString()

Parameters:

  • It does not accept any parameter.

Return Values:

  • It returns a new string representing the given string object.

Example 1: This example shows the basic use of the string.toString() Method in Javascript. 


Output
GfG

Example 2: Taking a string as input and printing it with the help of a string.toString() method.


Output
GeeksforGeeks

Example 3: Taking a string as input and printing it with the help of string.toString() method.


Output
GFGGFG

Example 4: In this example, we are converts the variable number to a string using the toString() method and output the result. The typeof operator confirms the type of our output as "string".


Output
42
string

We have a complete list of Javascript string methods, to check those please go through this article.

Supported Browsers:

  • Google Chrome 3
  • Microsoft Edge 12
  • Mozilla Firefox 3.0
  • Safari 5
  • Opera 10.5
Comment