Query String Parser/Builder
Parse and build URL query strings
The Query String Parser/Builder converts between URL query strings and structured key-value pairs, handling URL encoding, nested objects, array notation, and duplicate keys correctly in both directions. Paste a query string like ?user[name]=alice&colors[]=red&colors[]=blue&q=hello+world and get a clean table of decoded parameters, or input key-value pairs and get a properly encoded query string ready to append to any URL.
Understanding URL Query Strings
Query strings are the part of a URL that comes after the ? character, and they are one of the most common ways to pass data in web applications. Every time you filter a product list, submit a search form, or click a paginated link, the parameters travel as key-value pairs in the query string. They look simple on the surface -- just key=value pairs joined by & -- but the encoding rules, array conventions, and edge cases make them surprisingly tricky to work with by hand.
The core issue is that URLs have a restricted character set. Spaces, ampersands, equals signs, and most non-ASCII characters cannot appear literally in a query string because they have special meaning or are not valid in URIs. The application/x-www-form-urlencoded encoding standard handles this by replacing unsafe characters with percent-encoded sequences (%20 for a space) or the + shorthand for spaces. When you see q=hello+world or q=hello%20world in a URL, both mean the search term is "hello world" -- but knowing which encoding to expect depends on the context.
On top of basic encoding, different server frameworks have invented competing conventions for passing structured data like arrays and nested objects. PHP and Rails use bracket notation (colors[]=red&colors[]=blue), Java and Go use repeated keys (colors=red&colors=blue), and some frameworks support dot notation (user.address.city=NYC). This tool recognizes all of these conventions and shows you exactly what structure the server would receive, making it invaluable for debugging API calls and webhook payloads where parameter encoding issues are a frequent source of bugs.
How to Parse a Query String
- Paste the query string into the input field (with or without the leading
?). - Click Parse to extract all parameters into a structured table.
- Review each parameter's decoded value alongside its original encoded form.
- Edit individual values or copy the structured output for use in your code.
How to Build a Query String
- Enter key-value pairs as JSON, one-per-line (
key=value), or form data format. - Select encoding options (sort parameters, encoding standard).
- Click Build to generate a properly encoded query string.
- Copy the result and append it to your base URL.
Query String Parsing Examples
| Input Query String | Parsed Key | Parsed Value |
|---|---|---|
?name=John%20Doe | name | John Doe |
?q=hello+world | q | hello world |
?colors[]=red&colors[]=blue | colors[] | ["red", "blue"] |
?user[name]=alice&user[role]=admin | user[name], user[role] | alice, admin |
?tag=js&tag=react | tag (duplicate) | ["js", "react"] |
?redirect=https%3A%2F%2Fexample.com%2Fpath | redirect | https://example.com/path |
?price=9.99¤cy=%E2%82%AC | currency | € |
When to Use the Query String Parser/Builder
- Debugging OAuth flows -- Extract and inspect
state,code,redirect_uri, and token parameters from callback URLs. - Constructing API requests -- Build properly encoded query strings for REST APIs with filters, pagination, and sort parameters.
- Analyzing marketing links -- Break down UTM tracking parameters and campaign identifiers from shared URLs.
- Webhook debugging -- Parse incoming webhook callback URLs to understand what parameters the service is sending.
- Form data inspection -- Decode
application/x-www-form-urlencodedPOST body data that uses query string format. - Migration testing -- Verify that URL rewrites and redirect rules preserve query parameters correctly during site migrations.
How URL Query String Encoding Works
Query strings follow the application/x-www-form-urlencoded encoding standard, which builds on percent-encoding from RFC 3986.
Percent-Encoding Rules
Characters that are not safe in URLs are replaced with % followed by their two-digit hex code:
| Character | Encoded Form | Reason |
|---|---|---|
| Space | %20 or + | Delimiter in many contexts |
& | %26 | Separates key-value pairs |
= | %3D | Separates key from value |
# | %23 | Begins fragment identifier |
/ | %2F | Path separator |
@ | %40 | Used in authority component |
Array and Nested Object Notation
Different frameworks use different conventions for arrays and objects in query strings:
- Bracket notation:
colors[]=red&colors[]=blue(PHP, Rails) - Indexed notation:
colors[0]=red&colors[1]=blue(explicit ordering) - Repeated keys:
colors=red&colors=blue(Java, Go) - Nested objects:
user[address][city]=NYC(deep nesting) - Dot notation:
user.address.city=NYC(some Java frameworks)
Common Encoding Pitfalls
A frequent bug in hand-crafted query strings is double encoding. If you encode a value that is already encoded, %20 becomes %2520 (the % itself gets encoded), and the server receives a literal %20 string instead of a space. The parser detects and flags potential double-encoding so you can spot these issues immediately.
Practical Tips for Working with Query Strings
One of the most common mistakes developers make is building query strings through string concatenation rather than using a proper URL builder. It seems fast to write url + "?key=" + value, but the moment value contains an ampersand, a space, or a Unicode character, the resulting URL is malformed. Every major language has a built-in URL or query string builder -- URLSearchParams in JavaScript, urllib.parse.urlencode in Python, http_build_query in PHP -- and you should always use them.
When debugging API calls, pay attention to the difference between + and %20 for spaces. Both are valid in query strings under the application/x-www-form-urlencoded standard, but they behave differently in path segments. A + in a URL path is a literal plus sign, not a space. If your API endpoint receives search/hello+world in the path rather than the query string, it is not a space -- it is hello+world. This distinction causes subtle bugs when moving parameters between the path and query string.
If you are working with OAuth callback URLs, always parse the query string rather than using regex or string splitting. OAuth callbacks can contain base64-encoded tokens as parameter values, and these tokens may include characters like = and + that break naive parsing. A proper query string parser handles the encoding correctly and saves you from authentication bugs that only appear with certain token values.
Frequently Asked Questions
What is the difference between %20 and + for spaces?
In application/x-www-form-urlencoded encoding (HTML forms), spaces are encoded as +. In standard percent-encoding (RFC 3986), spaces are %20. Most servers accept both in query strings, but %20 is technically correct in path segments where + is a literal plus sign.
How do I handle duplicate keys in a query string?
The behavior depends on your server framework. Most frameworks (Express.js, Django, Rails) collect duplicate keys into an array. Some keep only the first or last value. The parser shows all occurrences so you can see exactly what was sent.
Does parameter order matter in query strings?
Technically, query string order is significant per the HTTP spec. In practice, most servers ignore order. If you need consistent strings for caching or comparison, use the sort option when building.
What is the maximum length of a query string?
There is no hard limit in the HTTP specification, but browsers and servers impose practical limits. Most browsers support URLs up to about 2,000 characters total. Web servers like Apache default to 8,190 bytes for the entire request line (method + URL + HTTP version). If you are approaching these limits, consider moving parameters to the request body using POST instead of GET.
How do I pass JSON data in a query string?
You can encode an entire JSON string as a single parameter value: ?data=%7B%22key%22%3A%22value%22%7D. However, this is fragile and hard to debug. For complex data, it is better to use a POST request with a JSON body. If you must use GET, flatten the JSON into individual parameters (?key=value&nested.field=data).
Can query string parameter names contain special characters?
Yes, but they must be percent-encoded. A parameter named user[name] is sent as user%5Bname%5D=value in the raw URL. Most frameworks decode this automatically. The parser shows both the encoded and decoded forms.
Related Tools
- URL Parser - Parse full URLs into scheme, host, port, path, and query components
- URL Normalizer - Normalize URLs by sorting parameters and removing defaults
- Bulk Add/Remove Query Params - Add or remove query parameters from multiple URLs at once
- Cookie Header Parser - Parse Cookie and Set-Cookie headers that often accompany query-based requests
- curl Command Builder - Build curl commands with properly encoded query parameters