Query string builder — encode key=value pairs into a URL, or decode one

Write one key=value pair per line and the tool percent-encodes each key and value and joins them into a query string, optionally on the end of a base URL; switch to Parse to turn an existing query into a table and JSON.

Live demo · real result from this tool
Mode
Encode spaces as

Full URL

https://shop.example.com/search?q=running%20shoes&size=42&color=red&color=blue&sort=price%3Aasc

Encoded pairs

KeyValueEncoded
qrunning shoesq=running%20shoes
size42size=42
colorredcolor=red
colorbluecolor=blue
sortprice:ascsort=price%3Aasc

Processed on your device — nothing is uploaded.

How to use the query string builder

  1. Leave Mode on Build.
  2. In the text box, write one key=value per line. Only the first = splits the line, so values may contain more = signs. A line without = becomes key= with an empty value.
  3. Add a Base URL (optional). If it already has a ?, the new pairs are joined with &.
  4. Pick Encode spaces as %20 or + (form style).
  5. Copy the full URL, or check each pair in the Encoded pairs table. To read a query instead, switch Mode to Parse and paste a URL or query string.

What it does and when to use it

Hand-written query strings break in small ways: an & inside a value starts a new parameter, a # cuts the URL short, and a + becomes a space on arrival. The builder encodes every key and value, so the server receives exactly what you typed. Use it to build a search link for a test, a redirect URL with a nested return URL, or a request to paste into a cURL to Code command.

Parse mode does the reverse for a URL copied from a browser or a log. You get a Key/Value table plus a JSON object, with repeated keys collected into an array.

How it works

Each key and value goes through JavaScript’s encodeURIComponent, which leaves letters, digits and - _ . ! ~ * ' ( ) as they are and percent-encodes everything else as UTF-8 bytes. With the + option, every %20 is then replaced with +. Pairs are joined with & and prefixed with ?. Parse mode drops everything up to the first ? and from the first #, then decodes the rest with URLSearchParams, the browser’s form-decoding rules.

Worked examples

A search link. The default lines with base https://shop.example.com/search and %20:

https://shop.example.com/search?q=running%20shoes&size=42&color=red&color=blue&sort=price%3Aasc

The colon in price:asc became %3A, and both colours are kept.

A nested return URL. Lines redirect=https://app.example.com/cb?x=1&y=2 and email=ana+test@example.com, spaces as +, no base:

?redirect=https%3A%2F%2Fapp.example.com%2Fcb%3Fx%3D1%26y%3D2&email=ana%2Btest%40example.com

Without encoding, the server would see y=2 as its own parameter and the email as “ana test”.

Parsing. …/search?q=running+shoes&color=red&color=blue&empty=#results gives rows such as q | running shoes, and the JSON turns color into an array of "red" and "blue", with "empty": "".

Limits and tips

  • A #fragment in the base URL is kept at the end, so …/p#top becomes …/p?a=1#top.
  • It does not sort, remove duplicates or check keys against an API.
  • To escape text for other places, such as JSON or shell, use the String Escaper. To inspect the finished link, paste it into the URL Parser.

Frequently asked questions

Should spaces be %20 or +?
Both are read as a space by form handlers and most web frameworks. %20 is safer in general because it means a space everywhere in a URL. Choose + only when the receiver expects classic HTML form encoding.
How do I send an array?
Repeat the key on separate lines, such as color=red and color=blue. Some back ends expect color[]=red instead; type the brackets in the key and they are encoded as %5B%5D. For nested objects, the JSON to Query String tool builds the keys for you.
Why is a literal + in my value turned into %2B?
Because a bare + in a query is read as a space. Encoding it keeps ana+test@example.com intact when the server decodes it.
Are spaces at the start or end of a value kept?
No. Each key and value is trimmed before encoding. If a value must start or end with a space, add it to the final URL as %20 by hand.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close