Skip to main content
The URL Parser tool breaks down URLs into their component parts, making it easy to inspect and understand URL structure. It extracts the protocol, hostname, port, pathname, query string, hash fragment, and provides a table view of all query parameters.

Features

  • Complete URL component extraction
  • Query parameter table display
  • Port detection with defaults
  • Hash fragment parsing
  • Invalid URL error handling
  • Supports all standard URL schemes

Use Cases

URL Debugging

Inspect URLs to understand their structure and troubleshoot issues

Query Analysis

Extract and review query parameters from API endpoints

Link Validation

Verify URL components are correctly formatted

Route Planning

Analyze URL patterns for routing and navigation logic

URL Structure

A URL consists of several components:
protocol://hostname:port/pathname?query#hash

Components

ComponentDescriptionExample
ProtocolScheme identifierhttps:, http:, ftp:
HostnameDomain or IP addressexample.com, 192.168.1.1
PortNetwork port8080, 443 (default)
PathnameURL path/api/v1/users
SearchQuery string?id=123&type=admin
HashFragment identifier#section-2

Input Format

Enter any valid URL:
https://example.com:8080/path/to/page?key=value&foo=bar#section
The URL must include at least a protocol and hostname. Relative URLs (e.g., /path/to/page) are not supported.

Output Format

The tool provides two outputs:
  1. Text Summary - Component breakdown
  2. Query Table - Key-value pairs of query parameters

Text Output

protocol: https:
hostname: example.com
port: 8080
pathname: /path/to/page
search: ?key=value&foo=bar
hash: #section

Query Parameter Table

KeyValue
keyvalue
foobar

Examples

Parse a standard HTTPS URL.Input:
https://www.example.com/products?category=books&sort=price
Output:
protocol: https:
hostname: www.example.com
port: (default)
pathname: /products
search: ?category=books&sort=price
hash: (none)
Query Parameters:
KeyValue
categorybooks
sortprice

Implementation Details

From lib/tools/engine.ts:125-144:
function parseUrl(value: string) {
  try {
    const parsed = new URL(value.trim());
    const queryRows: Array<Record<string, string>> = [];
    parsed.searchParams.forEach((v, k) => 
      queryRows.push({ key: k, value: v })
    );
    return {
      output: [
        `protocol: ${parsed.protocol}`,
        `hostname: ${parsed.hostname}`,
        `port: ${parsed.port || '(default)'}`,
        `pathname: ${parsed.pathname}`,
        `search: ${parsed.search || '(none)'}`,
        `hash: ${parsed.hash || '(none)'}`,
      ].join('\n'),
      table: queryRows,
    };
  } catch {
    return { output: 'Invalid URL' };
  }
}

URL API

The tool uses the native JavaScript URL API, which:
  • Validates URL syntax
  • Handles URL encoding/decoding
  • Provides structured access to components
  • Supports IPv4, IPv6, and domain names

Default Ports

ProtocolDefault PortExplicit Port Example
http:80http://example.com:8080
https:443https://example.com:8443
ftp:21ftp://example.com:2121
ws:80ws://example.com:3000
wss:443wss://example.com:3001
When the port matches the protocol’s default, it’s shown as (default) in the output.

Common Patterns

Extract Query Parameters

const url = new URL('https://example.com?name=Alice&age=30');
const name = url.searchParams.get('name');  // "Alice"
const age = url.searchParams.get('age');    // "30"

Build URLs Programmatically

const url = new URL('https://api.example.com/search');
url.searchParams.set('q', 'javascript');
url.searchParams.set('limit', '10');
url.toString();
// → https://api.example.com/search?q=javascript&limit=10

Check Protocol

const url = new URL(input);
if (url.protocol === 'https:') {
  console.log('Secure connection');
}

Get Base URL

const url = new URL('https://example.com:8080/path?query#hash');
const base = url.origin;  // "https://example.com:8080"

Special Cases

Relative URLs

This tool requires absolute URLs. Relative URLs like /path/to/page will fail. To parse relative URLs, provide a base URL:
new URL('/path', 'https://example.com')
// → https://example.com/path

Encoded Characters

Query parameters are automatically decoded:
Input:  https://example.com?name=John%20Doe&email=user%40example.com
Output: name=John Doe, email=user@example.com

Multiple Values

Query parameters with the same key:
https://example.com?tag=javascript&tag=tutorial&tag=beginner
In the table, only the last value is shown:
KeyValue
tagbeginner
To access all values, use url.searchParams.getAll('tag') in JavaScript.

URL Validation

The tool validates URLs using the WHATWG URL Standard. Invalid URLs return:
Invalid URL
Common invalid formats:
  • Missing protocol: example.com/path
  • Relative path: /path/to/page
  • Invalid characters: https://example .com
  • Malformed syntax: https:/example.com

Browser Support

The URL API is supported in all modern browsers:
  • ✅ Chrome 32+
  • ✅ Firefox 26+
  • ✅ Safari 7+
  • ✅ Edge (all versions)