How to Parse a URL — Breaking Down Every Part

URLs are more structured than they appear. Every part of a URL has a name and a specific meaning. Understanding that structure matters when building web applications, debugging routing issues, handling redirects, or manipulating links programmatically.

Parse any URL instantly with our URL Parser tool — see every component broken down clearly.

URL Structure — Every Component Named

Take this URL: https://api.toolchecking.com:8080/v1/results?q=ssl&limit=10#section-2

Breaking it down:

https — Protocol (or scheme). Defines how the client communicates with the server. Others: http, ftp, mailto, ws (WebSocket), file. api — Subdomain. Part of the hostname. toolchecking.com — Domain. Registerable label that identifies the organisation or site. :8080 — Port. Specifies which port the server listens on. HTTPS defaults to 443, HTTP to 80 — these are omitted when using defaults. /v1/results — Path. Hierarchical location of the resource on the server. ?q=ssl&limit=10 — Query string. Key-value pairs separated by & after ?. Used to pass parameters to the server. #section-2 — Fragment (or hash). Processed by the browser only, never sent to the server. Used for in-page navigation or client-side state.

Parsing URLs in Code

JavaScript — URL API

const url = new URL("https://api.toolchecking.com:8080/v1/results?q=ssl&limit=10#section-2");url.protocol // "https:" url.hostname // "api.toolchecking.com" url.port // "8080" url.pathname // "/v1/results" url.search // "?q=ssl&limit=10" url.searchParams.get("q") // "ssl" url.hash // "#section-2"

Python — urllib.parse

from urllib.parse import urlparse, parse_qsparsed = urlparse("https://api.toolchecking.com:8080/v1/results?q=ssl&limit=10") parsed.scheme # "https" parsed.netloc # "api.toolchecking.com:8080" parsed.path # "/v1/results" parsed.query # "q=ssl&limit=10" parse_qs(parsed.query) # {"q": ["ssl"], "limit": ["10"]}

URL Encoding

URLs can only contain a limited set of characters. Special characters must be percent-encoded: a space becomes %20, @ becomes %40, / becomes %2F when used in a query string value.

JavaScript: encodeURIComponent() encodes everything except letters, digits, and - _ . ~ Python: urllib.parse.quote() for encoding, urllib.parse.unquote() for decoding

The difference between encodeURI() and encodeURIComponent(): encodeURI() encodes a full URL and leaves characters like ? # / intact. encodeURIComponent() encodes individual components and encodes those characters. Use encodeURIComponent() for query parameter values.

Parse any URL and see every component clearly — protocol, domain, path, query, fragment

Try URL Parser Free →

FAQs

No. The fragment identifier (everything after #) is processed by the browser only and never included in HTTP requests. Servers cannot see it. This makes it useful for client-side navigation in single-page applications where you want state in the URL without server round trips. Server-side analytics tools cannot see fragment identifiers either.
There is no official limit in the URL specification, but practical limits exist. Most browsers support up to 2048 characters. IE had a hard limit of 2083 characters. Server frameworks typically have configurable limits — Apache defaults to 8190 bytes, Nginx to 8192 bytes. For URLs longer than 2000 characters, consider POST requests instead.
URI (Uniform Resource Identifier) is the broad category. URL (Uniform Resource Locator) is a URI that includes a location (how to access the resource). URN (Uniform Resource Name) is a URI that names a resource without specifying its location. In practice, URL and URI are used interchangeably in everyday web development contexts.
Scroll to Top
Checker Tools