Dev Tools icon

Dev Tools

A suite of utility tools for developers: Generators, converters, and transformers.

URL Parser

AI-generated

Summary

Parse the provided URL string into its components including protocol, hostname, port, pathname, hash, and query parameters.

Inputs

  • URL (required) — The full URL string to parse.

Output shape

a single JSON object with keys: protocol, hostname, port, pathname, hash, and searchParams (an object of query parameters)

Throws an error if the URL is invalid.

Examples

Example 1: Parsing a full URL

Provide a complete URL string like 'https://example.com:8080/path?foo=bar#section' to the 'URL' input parameter and execute the node; it will output components such as protocol (https:), hostname (example.com), port (8080), pathname (/path), hash (#section), and searchParams ({foo: 'bar'}).

Links

Discussion