URL parser

Parse URLs and extract components (protocol, host, path, etc.)

URL Parser

Parse and inspect all components of a URL

Protocol
Username
Password
Hostname
Port
Host
Origin
Pathname
Search
Hash
foo
baz

CORS explained

HTTP caching headers explained

URL encoding explained

REST vs GraphQL vs gRPC: which API style to use

TL;DR

What is URL parser?

A URL (Uniform Resource Locator) is composed of distinct components defined in RFC 3986: scheme (https), authority (user:password@host:port), path (/search), query (?q=foo), and fragment (#section). Parsing splits a URL into these parts for inspection or manipulation.

Common use cases

  • API debugging: extract individual query parameters from a long URL without manually reading percent-encoded strings
  • Redirect validation: confirm that a redirect target has the correct scheme, host, and path
  • URL construction: verify that programmatically built URLs have the structure you expect
  • Security review: inspect the host and path of a URL from an untrusted source before following it

Frequently asked questions

What is the difference between a path and a query string?

The path is the hierarchical portion of the URL after the host (/api/v1/users). The query string starts after the ? and contains key-value pairs (?id=42&format=json). Paths typically identify a resource; query strings provide additional parameters to filter or modify the response.

What is a URL fragment?

The fragment is the portion after # in a URL (e.g. #section-2). It is processed entirely by the browser and is never sent to the server. It is used to scroll to an element on a page or to pass state in single-page applications via hash routing.

See also

  • URL encoder: encode individual query parameter values after extracting them from a parsed URL
  • HTTP status codes: look up the meaning of a response status code when debugging requests to a URL you have just parsed