Node.js URL Complete Reference Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report The ‘url’ module provides utilities for URL resolution and parsing. The getters and setters implement the properties of URL objects on the class prototype, and the URL class is available on the global object.Example: JavaScript // Create a test URLSearchParams object const searchpar = new URLSearchParams("keya=vala&keyb=valb"); // Display the key/value pairs for (let pair of searchpar.entries()) { console.log(pair[0] + ', ' + pair[1]); } Output:keya, valakeyb, valbThe Complete list of URL is listed below:MethodsDescription URL()It provides utilities for URL resolution and parsingurl.toString()It is an inbuilt application programming interface(API) of the URL moduleURL.toJSON()Return the serialized URL of the URL object. url.domainToUnicode()Get the domain for the particular ASCII value.APIDescriptionhash Get and set the fragment portion of the URL.host APIGet and set the host portion of the URL.origin APIThis url.origin is an inbuilt application programming interface(API) of the URL classusername APIGet and set the username of URL. search APIGet and set the query part of URL. port APIGet and set the port portion of the URL.the port value may be a numberpathname APIGet and set the pathname portion of the URL.password APIGet and set the password portion of the URL. href APIIt is an Inbuilt application programming interface of class URL within the url modulehostname APIGet and set the hostname portion of the URL.pathToFileURL APIConverts the path to a file and ensures that the URL control characters (/, \, : ) fileURLToPath APIDecodes the file URL to a path string and ensures that the URL control characters (/, %)parse(urlString, parseQueryString, slashesDenoteHost) It takes a URL string, parses it, and it will return a URL object with each part of the address as properties.Special Schemes of protocol APIGet and set the protocol scheme of the URL.protocolGet and set the protocol portion of the URL.domainToASCIIIt is an inbuilt application programming interface of class URL within url module.domainToUnicodeIt is an inbuilt application programming interface of class URL within url module.resolve(from,to)It is an inbuilt method of class URL that resolves a target URL relative to a base URL.format(urlObject)It is an inbuilt API provided by URL class, which takes an object or string formatWith the help of url.format()method, we are able to format the hostname according to our needs.Class: URLSearchParamsClass: URLSearchParamsDescriptionappend()This method adds a key/value pair specified by the user.delete()This method deletes the parameter specified by the user and all its associated values.entries()Returns an iterator that allows iterating through all the key/value pairs present in the object.forEach()Returns an iterator that allows iterating through all values contained in this object with the help of a callback function.get()Returns the first value of the input search parameter.get()Get the value for a particular name entry present in the URL search params object.getAll()Returns all the values of the input search parameter in the form of an array.sort()This method uses a stable sorting algorithm.toString()Get the object of uri search params to the object as a string.keys()Get the iterator object containing all the name entries only of the URL search params object.values()In the URLSearchParams interface, the values() method returns an iterator set()Sets the value given as an input parameter.toString()Returns a query string that is suitable for use in a URL.keys()In the URLSearchParams interface, the keys() method returns an Iterator has()In the URLSearchParams interface, the has() method returns a Boolean Legacy urlObject:authReturn the string of parameters.hashIt is used for identifying the “fragment” portion of a URL.hostReturn the hostname in the URL as a string.searchGet the search query within the hostname which is followed by the ‘?’ character.protocolIt is used by the given hostname.hrefReturn the complete URL string along with the protocols(HTTP) and pathname or other search terms.queryCheck whether the query is a string or an object.slashesIt is used when one wants to check whether there is a need for ASCII valued forward-slash character (/) after the colon (:) portGet the numeric port portion of the host component within the hostname.pathname It is used by the given hostname. Comment K kartik Follow 2 Improve K kartik Follow 2 Improve Article Tags : Web Technologies Node.js Node-URL Explore Node.js Tutorial 3 min read Introduction & Installation NodeJS Introduction 3 min read Node.js Roadmap: A Complete Guide 6 min read How to Install Node.js on Linux 6 min read How to Install Node.js on Windows 5 min read How to Install NodeJS on MacOS 6 min read Node.js vs Browser - Top Differences That Every Developer Should Know 6 min read NodeJS REPL (READ, EVAL, PRINT, LOOP) 4 min read Explain V8 engine in Node.js 7 min read Node.js Web Application Architecture 3 min read NodeJS Event Loop 5 min read Node.js Modules , Buffer & StreamsNodeJS Modules 5 min read What are Buffers in Node.js ? 4 min read Node.js Streams 4 min read Node.js Asynchronous ProgrammingAsync Await in Node.js 3 min read Promises in NodeJS 7 min read How to Handle Errors in Node.js ? 4 min read Exception Handling in Node.js 3 min read Node.js NPMNodeJS NPM 6 min read Steps to Create and Publish NPM packages 7 min read Introduction to NPM scripts 2 min read Node.js package.json 4 min read What is package-lock.json ? 3 min read Node.js Deployments & CommunicationNode Debugging 2 min read How to Perform Testing in Node.js ? 2 min read Unit Testing of Node.js Application 5 min read NODE_ENV Variables and How to Use Them ? 2 min read Difference Between Development and Production in Node.js 3 min read Best Security Practices in Node.js 4 min read Deploying Node.js Applications 5 min read How to Build a Microservices Architecture with NodeJS 3 min read Node.js with WebAssembly 3 min read Resources & ToolsNode.js Web Server 6 min read Node Exercises, Practice Questions and Solutions 4 min read Node.js Projects 9 min read NodeJS Interview Questions and Answers 15+ min read Like