URL Parser

Decompose URLs into protocol, hostname, port, pathname, query parameters, and hash fragments for debugging and analysis.

Back to all tools on ToolForge

More in Web & Network

Input URL



Components



Query Parameters


About URL Parser

This URL parser decomposes a complete URL into its constituent parts: protocol, hostname, port, pathname, search query string, individual query parameters, and hash fragment for detailed inspection and debugging.

It is useful for API endpoint debugging, OAuth callback verification, redirect chain analysis, tracking link inspection, deep link validation, query parameter auditing, SPA route debugging, and understanding the exact structure of complex URLs with multiple parameters.

URL Structure Breakdown

A complete URL follows this structure:

URL: https://www.example.com:8080/path/to/page?user=123&token=abc#section

Components:
├── protocol:  https://
├── hostname:  www.example.com
├── port:      8080
├── pathname:  /path/to/page
├── search:    ?user=123&token=abc
├── hash:      #section
└── host:      www.example.com:8080 (hostname + port)

Query Parameters (parsed):
├── user:  123
└── token: abc

URL Component Reference

Component Description Example
protocol The scheme/protocol used https:, http:, ftp:, mailto:
hostname The domain name (without port) www.example.com, api.github.com
port Explicit port number (if any) 8080, 3000, 443 (default for HTTPS)
pathname The path to the resource /api/v1/users, /docs/index.html
search Query string including ? ?id=123&sort=desc
hash Fragment identifier including # #top, #section-2, #comment-456
host Hostname + port combined example.com:8080

Common URL Examples by Protocol

Protocol Example URL Use Case
https: https://api.example.com/v1/users?id=123 Secure web APIs
http: http://localhost:3000/dev Local development
mailto: mailto:[email protected]?subject=Hello Email links
tel: tel:+1-555-123-4567 Click-to-call links
ftp: ftp://files.example.com/pub/file.zip File transfers

Query Parameter Parsing Details

Input URL:
https://shop.example.com/products?category=shoes&size=10&size=11&color=red#details

Parsed Query Parameters:
{
  "category": "shoes",
  "size": ["10", "11"],    // Array for duplicate keys
  "color": "red"
}

Hash Fragment: #details


URL Encoding in Parameters

Special characters in query values are percent-encoded:

Encoded Decoded Use Case
%20 Space search?q=hello%20world
%26 Ampersand (&) data=a%26b (value contains &)
%3D Equals (=) formula=x%3D1 (value contains =)
%2F Forward slash (/) url=http%3A%2F%2Fexample.com
%3F Question mark (?) redirect=%3Fhome

Common Use Cases

Port Reference for Common Protocols

Protocol Default Port When Explicit Port Needed
HTTP 80 Development servers, proxies
HTTPS 443 Custom SSL endpoints
FTP 21 Alternative FTP servers
SSH 22 Remote Git, SCP, SFTP
Local Dev Varies (3000, 8000, 8080) Development servers

Parsing Edge Cases

Edge Case 1: Relative URL
Input:  /path/to/page?query=1
Result: Requires base URL to resolve protocol/host

Edge Case 2: Empty Parameter Value
Input:  ?flag&key=value
Result: flag="", key="value"

Edge Case 3: Duplicate Keys
Input:  ?tag=foo&tag=bar&tag=baz
Result: tag: ["foo", "bar", "baz"]

Edge Case 4: Nested/Encoded URLs
Input:  ?redirect=https%3A%2F%2Fexample.com%3Ffoo%3D1
Result: redirect: "https://example.com?foo=1"

Edge Case 5: Fragment with Query
Input:  /page?a=1#section
Result: search="?a=1", hash="#section"
        (hash is NOT part of query string)

Frequently Asked Questions

What are the components of a URL?
A URL consists of: protocol (https://), hostname (www.example.com), port (optional, :8080), pathname (/path/to/resource), search query (?key=value&foo=bar), and hash fragment (#section). The hostname may include subdomain and TLD. Port 443 is default for HTTPS, 80 for HTTP.
What is the difference between hostname and host?
hostname is just the domain name (www.example.com). host includes the domain plus port if specified (www.example.com:8080). If no explicit port is given, host and hostname appear identical. Use hostname when you only need the domain; use host when port matters.
How are query parameters parsed?
Query parameters follow the ? in a URL and are formatted as key=value pairs separated by &. The parser decodes URL-encoded values (%20→space, %26→&). Duplicate keys (tag=foo&tag=bar) are collected into arrays. Empty values and boolean flags are preserved as-is.
What is a URL hash fragment used for?
The hash fragment (#section) identifies a specific section within a page. It's never sent to the server—only used client-side for scrolling to anchors, single-page app routing, or tracking scroll position. Common in documentation sites (#installation, #api-reference) and SPA navigation.
Why parse URLs for debugging?
Parsing reveals the exact structure of complex URLs: verifying redirect chains have correct parameters, checking API endpoints use proper authentication tokens, confirming tracking pixels fire with right UTMs, debugging OAuth callback URLs, and ensuring deep links route to correct app sections.
What is URL encoding and how does it affect parsing?
URL encoding (percent-encoding) converts special characters to %XX format. Spaces become %20, ampersands %26, equals %3D. During parsing, these are automatically decoded for display. A parameter value of 'hello%20world' displays as 'hello world'. This ensures safe transmission while maintaining readability.