Skip to content
gohacks.dev
APIs

URL Parser

Break any URL into protocol, credentials, host, port, path, query parameters and fragment, decoded, using the same URL parser as browsers and Node.js.

Free · No sign-up · Your inputs stay in your browser

Input

Break a URL into its parts

Output

api.example.com

Protocolhttps:
Usernameuser
Passwords3cret
Hostnameapi.example.com
Port8443
Originhttps://api.example.com:8443
Path/v2/orders/1042
Query?expand=items&expand=customer&utm_source=newsletter
Fragment#summary
Path segmentsv2 · orders · 1042
Query keyDecoded value
expanditems
expandcustomer
utm_sourcenewsletter

Parsed by the WHATWG URL standard that browsers and Node.js use. PHP's parse_url() follows RFC 3986 instead and disagrees on edge cases, such as a backslash in the path or a username containing @.

Runs in this browser. Nothing you paste is sent to a server.

Two standards

Browsers and Node.js follow the WHATWG URL Standard; PHP's parse_url() and many older libraries follow RFC 3986. They agree on ordinary URLs and disagree on edge cases such as backslashes, spaces and an @ in the username, which is exactly what URL-based attacks exploit. When a server checks a URL that a browser will later follow, parse it the way the browser will.

Connection strings are URLs

Database DSNs like postgres://user:pass@host:5432/db?sslmode=require parse the same way, which makes this a quick way to check a DATABASE_URL. A password containing @, : or / must be percent-encoded in the URL.

Share

Frequently asked questions

Why is the port empty?
The URL uses the scheme's default port (443 for https, 80 for http), which the URL standard does not repeat. The tool shows the default next to it.
How do I put a special character in a password inside a URL?
Percent-encode it: @ becomes %40, : becomes %3A and / becomes %2F. encodeURIComponent() does this.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools