URL Parser

Parse URLs into parts.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

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

1
Step 1
Paste the URL.
2
Step 2
Press Run.
3
Step 3
Read the parts, or copy the JSON.

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?
Paste the URL and read hostname.
What is the difference between host and hostname?
host includes the port number if there is one; hostname does not.
How do I get the query parameters?
Copy the search value into the query string parser to split it into keys and values.
What if my URL has no http://?
https:// is added automatically.

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 YouTube
  • Learn JSON - Full Crash Course

    freeCodeCamp.org

    JSON is the payload format behind many developer tools here.

    Watch on YouTube