- Home
- Tools
- Developer Tools
- URL Parser
- Query String Parser
Query String Parser
Paste a URL, or only its query string, and get the parameters decoded in a table. Edit, reorder or remove them, or copy them as JSON.
Query parameters (6)
In the URL:
q=flat+whiteIn the URL:
sort=price%3AascTracking parameter
Parts
- Scheme
- https
- Host
- shop.example.com
- Port
- 443Not in the URL: 443 is the default for https
- Path
- /search
- Query
- ?q=flat+white&size=large&size=small&sort=price%3Aasc&page=2&utm_source=newsletter
- Fragment
- #results
- Origin
- https://shop.example.com
Path segments
- 1search
Decoded for reading
https://shop.example.com/search?q=flat white&size=large&size=small&sort=price:asc&page=2&utm_source=newsletter#results
Every %XX is turned back into its character. Easier on the eyes, but not always a working link: a decoded & or # changes where the parts end.
How a query string is read
The query string is the part of a URL behind the first question mark, up to a hash sign if there is one. Reading it takes three steps.
- Cut it at every
&. Each piece is one parameter. - Cut each piece at its first
=: the name is in front of it, the value behind it. A piece without=is a name with an empty value. - Decode both. A
+becomes a space, and every%with two hex digits becomes one byte; the bytes together are read as UTF-8.
The address this page opens with, taken apart that way:
| Piece | Name | Value |
|---|---|---|
Pieceq=flat+white | Nameq | Valueflat white |
Piecesize=large | Namesize | Valuelarge |
Piecesize=small | Namesize | Valuesmall |
Piecesort=price%3Aasc | Namesort | Valueprice:asc |
Piecepage=2 | Namepage | Value2 |
Pieceutm_source=newsletter | Nameutm_source | Valuenewsletter |
A query string by itself, such as q=tea&page=2, can be pasted as well. It is read the same way, and what you change is written back without a question mark.
Characters that cannot go into a value as they are
A character that has a job in a URL has to be percent-encoded when it is meant as plain text. The table does that for you when you type a name or a value.
| Character | Written as | Why |
|---|---|---|
| Characterspace | Written as%20 | A space cannot be part of a URL at all. In a query a plus sign stands for one too. |
Character& | Written as%26 | Would start the next parameter. |
Character= | Written as%3D | Separates a name from its value. |
Character+ | Written as%2B | Left as it is, it is read as a space. |
Character# | Written as%23 | Would end the query and start the fragment. |
Character% | Written as%25 | Starts an escape itself. |
Characteré | Written as%C3%A9 | Everything outside ASCII is written as its UTF-8 bytes, two for this letter. |
The same name more than once
Nothing forbids size=large&size=small, and the table keeps both. What a program makes of it differs. In JavaScript, URLSearchParams.get("size") returns the first value and getAll("size") returns both. PHP keeps the last one, unless the name ends in square brackets, as in size[]=large&size[]=small: then it builds an array.
A name without a value
?debug and ?debug= both carry a parameter called debug with nothing in it, and URLSearchParams gives an empty text for either. They are different texts all the same, so an address that was signed or cached in one form does not match the other. The table leaves a parameter in the form it came in.
The URL parser page covers the rest of an address: scheme, host, port, path and fragment, and which tracking parameters the button removes.