URL parser

Paste a URL to see its parts and every query parameter, decoded.

This tool runs in your browser. We never send what you type or paste to a server.

Parts of a URL

https://user@shop.example.com:8080/products/shoes?color=red&size=9#reviews

  • Protocol: https:
  • Host: shop.example.com, with optional port 8080
  • Path: /products/shoes
  • Query: color=red&size=9
  • Fragment: #reviews, which is never sent to the server

Tracking parameters

Parameters such as utm_source, gclid and fbclid track where clicks come from. The parser flags them and gives you a clean copy of the URL without them.

Example

https://user@shop.example.com:8080/products/shoes?color=red&size=9#reviews

protocol  https:
host      shop.example.com
port      8080
path      /products/shoes
query     color = red, size = 9
fragment  reviews

Addresses without a scheme, such as localhost:3000/api, are read as https.

How the parser reads a URL

The tool uses the browser's own URL class, which follows the WHATWG URL Standard, so the parts it shows are the parts a browser would use. That has some visible effects:

  • The host is lower-cased, and non-ASCII names are shown in their punycode form, so münchen.example appears as xn--mnchen-3ya.example.
  • A port that is the default for the scheme (443 for https, 80 for http) is dropped and shown as "(default)".
  • Paths such as /a/./b/../c are normalised to /a/c.
  • In the query, + is decoded as a space and %25 as a percent sign. In the path, + stays a plus.
  • A key that appears more than once, such as tag=a&tag=b, is listed once per value, in order.

Parsing URLs in code

JavaScript, in browsers and Node:

const u = new URL('https://shop.example.com:443/search?q=red+shoes&tag=a&tag=b&note=50%25#top');
console.log(u.host, u.port === '');               // → shop.example.com true   the default port is dropped
console.log(u.searchParams.get('q'));             // → red shoes   + means a space in the query
console.log(u.searchParams.getAll('tag'));        // → [ 'a', 'b' ]
console.log(u.searchParams.get('note'));          // → 50%
console.log(new URL('https://münchen.example/').hostname);         // → xn--mnchen-3ya.example
console.log(new URL('/api/v1?x=1', 'https://example.com/docs/').href);   // → https://example.com/api/v1?x=1

The URL constructor throws on anything without a scheme unless you pass a base URL as the second argument. The parser on this page adds https:// for you, which is why localhost:3000/api works here:

try { new URL('example.com/path'); } catch (e) { console.log(e.code); }   // → ERR_INVALID_URL   no scheme, no base

Python's urllib.parse splits more loosely. It does not throw, so a missing // gives you an empty host rather than an error:

s = urlsplit('https://user@shop.example.com:8080/products/shoes?color=red&size=9&size=10#reviews')
print(s.scheme, s.hostname, s.port, s.path)   # → https shop.example.com 8080 /products/shoes
print(parse_qs(s.query))                      # → {'color': ['red'], 'size': ['9', '10']}
print(s.fragment)                             # → reviews
print(urlsplit('example.com/path').netloc == '')   # → True   without // the host is read as part of the path

To drop tracking parameters yourself, rebuild the query from the pairs you keep:

q = [(k, v) for k, v in parse_qsl(s.query) if not k.startswith('utm_')]
print(urlunsplit(s._replace(query=urlencode(q), fragment='')))   # → https://user@shop.example.com:8080/products/shoes?color=red&size=9&size=10

Gotchas

  • The clean URL can change encoding. When tracking parameters are removed, the remaining query is written back in form encoding, so %20 becomes +. Servers decode both to a space, but a signed URL (an S3 pre-signed link, for example) can stop working if any byte changes. Remove parameters by hand from signed links.
    const v = new URL('https://example.com/?q=a%20b&utm_source=x');
    v.searchParams.delete('utm_source');
    console.log(v.search);                            // → ?q=a+b   the rest of the query is re-encoded
  • Credentials in URLs. https://user:pass@host/ is still valid syntax. The parser shows the username but never the password; anything you paste in a URL ends up in browser history and server logs, so avoid putting secrets there.
  • Look-alike hosts. In https://example.com@evil.test/ the host is evil.test; everything before the @ is a username. Reading the Host row is a quick way to check a suspicious link.

Questions

Is the fragment sent to the server?

No. Everything after # stays in the browser.

Can it remove tracking parameters?

Yes. Copy the "clean URL", which drops common tracking parameters like utm_*, gclid and fbclid.

What does the clean URL remove?

Tracking parameters such as utm_source, utm_medium, gclid and fbclid, which you usually do not want to share or store.

What is the difference between the host and the origin?

The host is the name and optional port, such as shop.example.com:8080. The origin adds the scheme, as in https://shop.example.com:8080, and is what browsers compare for the same-origin policy and CORS. The parser shows both.

Why does my query parameter value have a space instead of a plus?

In query strings a + means a space, a rule inherited from HTML form encoding, so ?q=a+b decodes to "a b". To send a literal plus, encode it as %2B, which encodeURIComponent does for you.

How do I get a single query parameter in JavaScript?

Use new URL(href).searchParams.get("name"), which returns the decoded value or null if the parameter is missing. For keys that appear several times, getAll returns every value as an array.