URL Parser icon

URL Parser

Safely extract various elements from an URL

Overview

This node parses a given URL string and extracts its various components safely. It is useful when you need to break down URLs into their constituent parts for further processing, such as extracting query parameters, hostname, or path segments.

Common scenarios include:

  • Extracting query parameters from URLs for filtering or routing.
  • Analyzing URL structure in web scraping or data transformation workflows.
  • Validating and normalizing URLs before using them in API calls or redirects.

For example, if you input the URL https://example.com:8080/path?search=test#section, the node will output each part like protocol (https:), host (example.com:8080), pathname (/path), search parameters ({search: "test"}), and hash (#section).

Properties

Name Meaning
URL The full URL string to parse. This is a required field.

Output

The node outputs a JSON object with the following fields extracted from the input URL:

  • href: The full normalized URL string.
  • protocol: The protocol scheme (e.g., http:, https:).
  • host: The hostname plus port number (if specified).
  • hostname: The domain name or IP address without port.
  • port: The port number as a string (empty if not specified).
  • pathname: The path section of the URL.
  • search: The query string including the leading ?.
  • searchParams: An object representing key-value pairs of query parameters.
  • hash: The fragment identifier including the leading #.
  • origin: The origin consisting of protocol, hostname, and port.

The output is always JSON; there is no binary data output.

Dependencies

  • No external services or APIs are required.
  • The node relies on the standard JavaScript URL class available in the runtime environment.

Troubleshooting

  • Invalid URL error: If the input URL string is malformed or invalid, the node will throw an error when trying to create a new URL object. Ensure the URL is properly formatted and includes a protocol (e.g., http:// or https://).
  • Empty or missing URL: Since the URL property is required, leaving it empty will cause the node to fail. Always provide a valid URL string.
  • Unsupported URL schemes: The node uses the standard URL constructor which supports common schemes like HTTP, HTTPS, FTP, etc. Custom or unsupported schemes may cause errors.

Links and References

Discussion