TToolbox
🔎

URL Parser

Break a URL into parts and params

About this tool

Uniform Resource Locators (URL, RFC 3986) serve as the address standard for navigating the global Internet. A complete URL combines Protocol, Hostname, Port, Pathname, Query Parameters, and Hash fragments into one string. Manually auditing long URLs packed with marketing tracking tags and nested callback targets is difficult. This tool dissects URLs into component trees and parses query strings into clean tables and JSON dictionaries.

How to Use This Tool (Step-by-Step)

1

Paste Raw URL String

Paste your destination URL or relative API path into the address bar. The parser accepts standard and custom protocols.

2

Inspect Components & Query Table

The tool immediately parses each segment: Protocol, Hostname, Port, Pathname, alongside a structured key-value query parameter table.

3

Copy Parameters or Export JSON

Copy extracted parameter values with a single click, or export the entire query dictionary as a structured JSON object.

WHATWG URL Standard Compliance

Adheres strictly to the modern browser WHATWG URL standard, distinguishing origin, host, and hostname without regex flaws.

Structured Query String Parsing

Automatically unrolls dense query parameters into readable key-value tables and handles percent-decoding transparently.

100% Client-Side Privacy

Parsing executes entirely within local browser memory. User session tokens and private intranet IPs inside query strings are never transmitted.

URL Architecture & Common Developer Gotchas

  • •Understand host vs hostname: `hostname` contains only the domain/IP (`example.com`); `host` includes the port (`example.com:8080`). Critical for CORS headers.
  • •Hashes never reach the server: Browsers strip `#fragments` before transmitting HTTP requests. Hashes are purely client-side anchors and SPA routing targets.
  • •Multi-value query keys: Repeated parameters (`?id=1&id=2`) get overwritten in plain dictionaries. Use `searchParams.getAll('id')` to retrieve all array items.

Code & Transformation Examples

Complete URL Anatomy Breakdown Benchmark

Raw Target URL
https://api.example.com:8080/v1/users/search?keyword=前端&page=2&sort=desc#results
Dissected URL Components
• Protocol (协议) : https:
• Hostname (主机) : api.example.com
• Port (端口)     : 8080
• Pathname (路径) : /v1/users/search
• Search (查询串) : ?keyword=前端&page=2&sort=desc
• Hash (锚点)     : #results

* Query values are automatically percent-decoded for effortless human inspection.

Modern JavaScript URL API Implementation

Using Native URL API
const myUrl = new URL("https://example.com/path?foo=1&bar=hello#title");
console.log(myUrl.hostname); // "example.com"
console.log(myUrl.pathname); // "/path"
Reading URLSearchParams
const params = Object.fromEntries(myUrl.searchParams.entries());
console.log(params); // { foo: "1", bar: "hello" }
console.log(myUrl.searchParams.get("foo")); // "1"

* `URL` and `URLSearchParams` provide standard zero-dependency parsing across all modern runtimes.

Frequently Asked Questions

Q: Why does `new URL('/path')` throw a TypeError?

A: WHATWG standards require valid schemes and hosts. For relative paths, you must provide a base origin: `new URL('/path', window.location.origin)`.

Q: Can URLs legally contain raw spaces or Chinese characters?

A: No. While browser address bars render Unicode visually, underlying network sockets convert spaces to `%20` and characters into percent-encoded UTF-8 bytes.

Q: Does changing ports trigger Cross-Origin (CORS) restrictions?

A: Yes. Under the Same-Origin Policy, any difference in protocol, hostname, or port constitutes a distinct origin, triggering cross-origin CORS barriers.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/