VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-querystring-unescape-method/

⇱ Node.js querystring.unescape() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js querystring.unescape() Method

Last Updated : 8 Apr, 2021

On the specified str, the querystring.unescape() method decodes URL percent-encoded characters. This method converts a percent-encoding string into a normal string. It means it decodes any percent-encoding string into a normal string by removing the % symbol. This method iterates through the string and removes the % encoding where needed on the specified str.

The queryString.unescape() function is used by querystring.parse() and is not well known for direct usage. It's being imported mainly to enable program code to have a changeable decoding implementation by assigning queryString.unescape to a different function if necessary.

Syntax:

querystring.unescape(str);

Parameters: This function accepts only one parameter, which is described below.

  • Str: It is the URL percent-encoded characters that are going to be decoded into a normal string.

Return value: It returns a normal string after decoding the URL percent-encoded characters.

Note: Install querystring using the below command.
npm i querystring

Below are the following examples to explain the concepts of the query string.unescape function.

Example 1:  In this example, we are encoding a URL percent-encoded string.

Index.js

Run index.js file using below command:

node index.js

Output:

Decoded string: I love geeksforgeeks

Example 2: In this example, we are decoding a  URL percent-encoded string using querystring.unescape( ) function and decodeURIComponent function and print the output of both the functions.

Output:

Decoded string using unescape: I love geeksforgeeks
Decoded string using decodeURIComponent: I love geeksforgeeks
both strings are equal
Comment

Explore