URL Parser
Split an absolute hierarchical URL into protocol, host, port, path, query, and fragment components. Bracketed IPv6 hosts and user-info prefixes are supported.
Description
Split an absolute hierarchical URL into protocol, host, port, path, query, and fragment components. Bracketed IPv6 hosts and user-info prefixes are supported.
URL Parser: Split an absolute hierarchical URL into protocol, host, port, path, query, and fragment components. Bracketed IPv6 hosts and user-info prefixes are supported.
When to use URL Parser
Use this parser to convert a string in the named grammar into a structured value while making accepted syntax and failures explicit.
- URL
- Absolute URL to parse.
How URL Parser works
Split an absolute hierarchical URL into protocol, host, port, path, query, and fragment components. Bracketed IPv6 hosts and user-info prefixes are supported. The tool evaluates the supplied inputs together and returns the named outputs below; it does not infer omitted operating conditions or change the units shown.1
- Protocol
- Protocol including the trailing colon.
- Host
- Host name or bracketed IPv6 address, excluding user info and port.
- Port
- Port as a string, empty when absent.
- Path
- Path beginning with a slash.
- Query
- Query string without the leading question mark.
- Fragment
- Fragment identifier without the leading hash.
Limitations and assumptions
- Parsing rules depend on locale, radix, encoding, escaping, duplicate fields, whitespace, overflow, rounding, time zone, units, and ambiguity policy. Successful parsing does not validate business meaning or make untrusted input safe.
- Use finite inputs in the displayed units and preserve more precision than the final presentation requires. Independently verify safety-critical, financial, compliance, or production decisions.
Alternative or Complementary approaches
Reject trailing or ambiguous content, preserve the original input, schema-validate the parsed value, and test malformed, boundary, and adversarial cases.
References
-
URL — Wikipedia contributors
Similar or alternative tools
- Query String Parser
Parse a URL query string into an object of decoded keys and string values (repeated keys keep the last value).
- Cache-Control Header Parser
Tokenize an RFC 9111 Cache-Control header into a record of directives; valueless flags become true and numeric values become numbers.
- Currency Parser
Parse a currency amount using an explicit currency code and number format.