URL Parser
Parse URLs into parts.
About this tool
Paste a URL and see its parts as JSON: protocol, host, hostname, port, pathname, search, hash and origin. If you leave off the scheme, https:// is assumed.
How to use
How it works
The URL is parsed with the browser's standard URL class, the same one JavaScript code uses. host includes the port when one is given and hostname does not. The origin is protocol + host. The query string comes back as the raw search value, so use the query string parser to split it into keys.
Worked example
A URL with port, query and hash
- Input
- https://user@example.com:8080/a/b?x=1&y=2#top
- Output
- { "href": "https://user@example.com:8080/a/b?x=1&y=2#top", "protocol": "https:", "host": "example.com:8080", "hostname": "example.com", "port": "8080", "pathname": "/a/b", "search": "?x=1&y=2", "hash": "#top", "origin": "https://example.com:8080" }
- Walkthrough
- host keeps:8080 while hostname does not. The user@ part is not listed separately, but stays in href.
Limitations
- A scheme-less input like example.com/path is assumed to be https.
- Username and password are not shown as their own fields.
- Invalid URLs return an error.
Questions
How do I get the domain from a URL?
What is the difference between host and hostname?
How do I get the query parameters?
What if my URL has no http://?
Features
- Nine URL parts
- Scheme optional
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
How base64 encoding works
Andrew Schmelyun
Mental model for Base64 encode/decode tools.
Watch on YouTubeLearn JSON - Full Crash Course
freeCodeCamp.org
JSON is the payload format behind many developer tools here.
Watch on YouTube
- MDN Web Docs
MDN
Primary reference for web APIs these developer tools touch.
- Introduction to JSON Web Tokens
jwt.io
JWT structure for decoder and debugger pages.