How to Parse a URL: Parts and Query Parameters
Last updated: · 3 min read
Looking at a web address you see a protocol, a domain, a path, a query and a hash all in one string, but software has to read each part separately. This guide explains how a URL is split according to the RFC 3986 syntax and how browsers apply the WHATWG URL standard to do the same job. It shows why %20 becomes a space and why + means a space only inside a query string. Every output in the example is the real result of the URL Parser tool.
Formula
address = scheme ":" "//" [user [":" password] "@"] host [":" port] path ["?" query] ["#" fragment] 1. If there is no scheme (for example www.example.com), https:// is added in front. 2. The scheme is read up to the first ":"; the host and port come from the part after "//". 3. If no port is written, the default for the scheme is shown (443 for https:, 80 for http:). 4. The query is split at "&" into name=value pairs; "+" becomes a space and %XX becomes the byte with that hexadecimal value. 5. The fragment is the part after "#"; it is never sent to the server.
Parsing follows RFC 3986 for the generic syntax and the WHATWG URL Standard for browser behaviour. Query parameters are decoded with the application/x-www-form-urlencoded rule, so a + in the query means a space, while a + in the path stays as it is. A user name and password may appear in a URL, but they are discouraged for security reasons.
What the inputs mean
- URL
- The full address you copied from the browser bar or use in code. If no protocol is given, the tool assumes https://; characters such as spaces are shown as they are.
Worked example: An address with query parameters
- Input: https://www.example.com/path?q=hello%20world&lang=tr#section.
- The scheme is https, so the port is not written and the default 443 is shown: Port: 443 (default).
- “/path” is the path. There is no user name, so the tool prints User: (none).
- The query splits into two pairs, q=hello%20world and lang=tr. %20 is decoded to a space, so the output reads q = hello world.
- “#section” is the hash and appears as Fragment (hash): section.
Result: Tool output: Protocol: https, Host: www.example.com, Port: 443 (default), Path: /path, Query parameters (2): q = hello world and lang = tr, Fragment (hash): section.
How to read the result
The parsed values are shown decoded, so if you send the same address to a server you may need to encode it again. The hash is used only inside the browser and is not sent to the server. As a general rule, passwords and personal data should never be placed in an address that you share.
Common mistakes
- Treating a + in the query as a plus sign. In form encoding + means a space, but in the path it stays a plus.
- Using an address with spaces as it is. Spaces must be written as %20 or the address may break.
- Guessing the default port wrongly. The default is 443 for https and 80 for http; the “(default)” label in the output shows which one applies.
- Confusing the hash with the query. Everything after # is kept in the browser and is not sent to the server.
- Leaving a password in the address. A user:pass@ prefix can appear in browser history and server logs, so credentials should not be shared this way.
Frequently asked questions
What happens if I leave out the protocol?
The tool assumes https:// and parses the address on that basis. For real use it is better to type the full address, so that the right scheme is chosen.
Why does %20 in a query turn into a space?
%20 is the hexadecimal value 20, which is the ASCII space character. The parser decodes query values, so the result displays a space.
What if the same parameter appears twice?
Each pair is listed on its own line and the order is kept. Server frameworks differ in whether they keep the first value, the last one or all of them.
Does this tool send my address to a server?
The page parses the address with code that runs in your browser. Even so, avoid pasting addresses that contain secrets or tokens.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.