URL Parser
Breaks a URL into its components and query parameters
This tool runs in your browser. No data leaves your device.
- Protocol
- Origin
- Host
- Hostname
- Port
- Pathname
- Hash
- Username
- Password
Query parameters
| Key | Value |
|---|
How It Works
A URL has six components: protocol, host, port, pathname, search, hash. This
tool uses JavaScript’s built-in URL class, which implements the WHATWG URL
standard.
WHATWG vs RFC 3986
It helps to know the two main specs:
- RFC 3986 — older, stricter. Historically the basis for languages like Java/PHP.
- WHATWG URL Living Standard — modern, what browsers use. More forgiving.
Some URLs parse differently between the two specs. For example: should
http://example.com get a trailing / (WHATWG: yes, RFC 3986: not required).
This tool uses the WHATWG version — the interpretation modern browsers use.
Common sources of bugs
URLSearchParamsalways returns values as strings. Reading?count=5means you have to doNumber(searchParams.get('count')).- Repeated parameters: for
?tag=a&tag=b,searchParams.get('tag')returns only the first value.searchParams.getAll('tag')returns both. - Percent encoding:
%20is a space, while+means a space only in the query string. In the pathname,+is a raw character. - IDN (internationalized domains): parsing
münir.comnormalizes it toxn--mnir-loa.com(punycode).
Pathname trailing slash
Do /users and /users/ represent the same resource? In practice:
- REST APIs usually don’t distinguish them.
- Static file servers may distinguish them (
/users/redirects to the index). - For SEO, pick one canonical form and redirect from the other.
Privacy
The URL you paste is processed entirely in your browser.