How to use the url parser
- Paste a web address. It can be a full address, a relative path or a link such as mailto.
- Read the parts: scheme, user info, host, port, path, query and fragment.
- Check the path segments and query parameters, which are decoded and numbered.
- Look at the problems line to see anything that is likely to break the address.
Formula
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
authority = user info @ host : port
query parameters are split on & and at the first =
a plus sign in a query is read as a space and %XX is decoded
The first line is the pattern given in RFC 3986, appendix B. It splits any address into five parts without checking that they are valid.
An address with every part
The address https://user:pw@www.example.com:8443/a/b%20c/d.html?q=hello+world&tag=a&tag=b&empty=#top has the scheme https, the user info user:pw, the host www.example.com, the port 8443, the path /a/b%20c/d.html, the query q=hello+world&tag=a&tag=b&empty= and the fragment top.
The path has three segments: a, b%20c (decoded b c) and d.html. The query has four parameters: q with the value hello world, tag with the value a, tag again with the value b, and empty with an empty value. The page flags the repeated name tag. A relative path such as /docs/guide?page=2&sort=desc#intro has no scheme or host, and a mailto link puts the address in the path.
What each part is for
The scheme says how to reach the address, such as https or mailto. The host names the server and the port selects a service on it, and an omitted port means the default for the scheme. The path picks a resource, the query passes named values to it, and the fragment names a place within the page and is never sent to the server.
Putting a user name and password in an address is discouraged because they can leak into logs and shared links. Treat any address that carries one as sensitive.
Reading without changing
This page reads the address exactly as typed. It does not make the host lowercase, drop default ports or resolve dots in paths, so you see what was written, not what a browser would make of it. Everything happens in your browser and nothing is fetched. To encode or decode a part, use the URL Encoder and Decoder. To turn a query into JSON, use the Query String to JSON Converter, and to add tracking parameters, use the UTM Link Builder.
Assumptions and limits
- The address is split with the RFC 3986 pattern and is not validated against a list of schemes.
- Percent-encoded text is decoded as UTF-8 where possible.
- The address can be at most 2,000 characters.
- Nothing is requested from the address.
- The address shown when the page opens is an example.
Frequently asked questions
What is a fragment?
The part after the hash sign. It points to a place within the page, such as a heading, and browsers do not send it to the server.
Why are repeated parameter names flagged?
Some servers read only the first value, some the last and some all of them. Repeating a name is allowed but easy to misread, so the page points it out.
Why does a plus sign become a space?
In a query string, a plus sign stands for a space, a habit from HTML forms. In a path, a plus sign is just a plus sign, and the path column does not change it.
What problems does it look for?
Spaces in the address, a port that is not a number up to 65535, an odd scheme, an empty host after two slashes and a percent sign not followed by two hex digits.