Node.js querystring.encode() Function Last Updated : 08 Mar, 2021 Comments Improve Suggest changes Like Article Like Report The querystring.encode() method is used to produce a URL query string from the given object that contains the key-value pairs. The method iterates through the object’s own properties to generate the query string. It can serialize a single or an array of strings, numbers, and boolean. Any other types of values are coerced to empty strings. During serializing, the UTF-8 encoding format is used to encode any character that requires percent-encoding. To encode using an alternative character encoding, the encodeURIComponent option has to be specified. Syntax: querystring.encode( obj, sep, eq, options ) Parameters: This function accepts four parameters as mentioned above and described below: obj: Object that has to be serialized into the URL query string.sep: String that specifies the substring used to delimit the key and value pairs in the query string. The default value is “&”.eq: String that specifies the substring used to delimit keys and values in the query string. The default value is “=”.options: It is an Object which can be used to modify the behavior of the method. It has the following parameters:encodeURIComponent: It is a function that would be used to convert URL-unsafe characters to percent-encoding in the query string. The default value is querystring.escape(). Return Value: It returns a String that contains the URL query produced from the given object. Example 1: JavaScript const querystring = require('querystring'); let obj = { user: "pratik", isMale: true, role: ["admin", "editor", "manager"], } let output = querystring.encode(obj); console.log("Output: ", output); Output: Example 2: JavaScript const querystring = require('querystring'); let obj = { user: "pratik", isMale: true, role: ["admin", "editor", "manager"], } let output = querystring.encode(obj, '/', '->'); console.log("Output: ", output); Output: Reference:https://nodejs.org/api/querystring.html#querystring_querystring_encode Create Quiz Comment P pratikraut0000 Follow 0 Improve P pratikraut0000 Follow 0 Improve Article Tags : Technical Scripter Web Technologies Node.js NodeJS-function Node.js- querystring-Module +1 More Explore Introduction & Installation NodeJS Introduction3 min readNode.js Roadmap: A Complete Guide6 min readHow to Install Node.js on Linux6 min readHow to Install Node.js on Windows5 min readHow to Install NodeJS on MacOS6 min readNode.js vs Browser - Top Differences That Every Developer Should Know6 min readNodeJS REPL (READ, EVAL, PRINT, LOOP)4 min readExplain V8 engine in Node.js7 min readNode.js Web Application Architecture3 min readNodeJS Event Loop5 min readNode.js Modules , Buffer & StreamsNodeJS Modules5 min readWhat are Buffers in Node.js ?4 min readNode.js Streams4 min readNode.js Asynchronous ProgrammingAsync Await in Node.js3 min readPromises in NodeJS7 min readHow to Handle Errors in Node.js ?4 min readException Handling in Node.js3 min readNode.js NPMNodeJS NPM6 min readSteps to Create and Publish NPM packages7 min readIntroduction to NPM scripts2 min readNode.js package.json4 min readWhat is package-lock.json ?3 min readNode.js Deployments & CommunicationNode Debugging2 min readHow to Perform Testing in Node.js ?2 min readUnit Testing of Node.js Application5 min readNODE_ENV Variables and How to Use Them ?2 min readDifference Between Development and Production in Node.js3 min readBest Security Practices in Node.js4 min readDeploying Node.js Applications5 min readHow to Build a Microservices Architecture with NodeJS3 min readNode.js with WebAssembly3 min readResources & ToolsNode.js Web Server6 min readNode Exercises, Practice Questions and Solutions4 min readNode.js Projects9 min readNodeJS Interview Questions and Answers15+ min read Like