Node.js Query String Complete Reference
Last Updated :
23 Jul, 2025
Node.js query String module is used as utilities for parsing and formatting URL query strings. It can be used to convert query string into JSON object and vice-versa.
Example:
JavaScript
// Import the querystring module
const querystring = require("querystring");
// Specify the URL query string
// to be parsed
let urlQuery =
"username=user1&units=kgs&units=pounds&permission=false";
// Use the parse() method on the string
let parsedObject = querystring.parse(urlQuery);
console.log("Parsed Query:", parsedObject);
// Use the parse() method on the string
// with sep as `&&` and eq as `-`
urlQuery =
"username-user1&&units-kgs&&units-pounds&&permission-false";
parsedObject = querystring.parse(urlQuery, "&&", "-");
console.log("\nParsed Query:", parsedObject);
Output:
Parsed Query: [Object: null prototype] {
username: 'user1',
units: [ 'kgs', 'pounds' ],
permission: 'false'
}
Parsed Query: [Object: null prototype] {
username: 'user1',
units: [ 'kgs', 'pounds' ],
permission: 'false'
}
The Complete list of Query String are listed below: