H ToolHub / 所有工具 / URL 解析器
🌐 开发者工具

URL 解析器

在线 URL 解析工具,详细解析 URL 的各个组成部分,包括协议、域名、端口、路径、查询参数和哈希。

URL 结构详解

URL(Uniform Resource Locator,统一资源定位符)是互联网上标识资源位置的标准格式。理解 URL 的结构对 Web 开发、API 调试和 SEO 优化都非常重要。

URL 的组成部分:

  • 协议 (Protocol):如 https:、http:、ftp:
  • 主机名 (Hostname):如 www.example.com
  • 端口 (Port):如 80、443,通常可省略
  • 路径 (Pathname):如 /api/users/123
  • 查询参数 (Search):如 ?page=1&size=10
  • 哈希 (Hash):如 #section-1,用于页面内锚点

除完整 URL 外,也支持无协议域名(如 example.com/path)、协议相对地址(//cdn.example.com/a.js)以及相对路径(/api/users?page=1、?foo=bar、#section)。相对输入会解析路径与查询参数,主机相关字段留空;缺协议时自动按 https 补全并标注。

查询参数的值如果本身是合法 URL(https://、//host、带查询或哈希的绝对路径,含多次百分号编码),会递归展开。例如 OAuth 的 redirect_uri 里再带 productUrl 时,可逐层看到路径与参数。纯路径、文件名(如 readme.md?v=1)或无协议域名不会当嵌套 URL。内层须按规范编码(尤其是 & 写成 %26),工具不会把错误的第二个 ? 当成 & 去猜。

本工具基于浏览器 URL API,支持实时解析,所有处理在本地完成。

URL Structure Explained

A URL (Uniform Resource Locator) is the standard format for identifying resource locations on the internet. Understanding URL structure is essential for web development, API debugging, and SEO optimization.

URL components:

  • Protocol — e.g. https:, http:, ftp:
  • Hostname — e.g. www.example.com
  • Port — e.g. 80, 443, usually omitted
  • Pathname — e.g. /api/users/123
  • Search — e.g. ?page=1&size=10
  • Hash — e.g. #section-1, used for in-page anchors

Besides full URLs, it also accepts scheme-less hosts (example.com/path), protocol-relative URLs (//cdn.example.com/a.js), and relative inputs (/api/users?page=1, ?foo=bar, #section). Relative inputs show path and query with host fields blank; missing schemes are inferred as https and labeled.

If a query value is itself a URL (https://, //host, or an absolute path with query/hash, including multiple percent-encodings), it is expanded recursively—for example an OAuth redirect_uri that contains productUrl. Bare paths, filenames (readme.md?v=1), and scheme-less hosts are not treated as nested URLs. Inner URLs must be encoded correctly (especially & as %26); a stray ? is not treated as &.

This tool uses the browser URL API with real-time parsing. All processing is done locally.