use case
How to encode a URL query parameter value
Safely embed user input or special characters in a URL query string.
Query parameter values often contain characters that break URL parsing — spaces, ampersands, equals signs, and non-ASCII text. If these characters are not percent-encoded, the server receives a malformed query string or silently truncates the value. This guide shows how to encode any string for safe use as a query parameter value in under 10 seconds, without writing code.
Step-by-step guide
- Paste the raw value: Paste the text you want to use as a query parameter value — a search term, a redirect URL, a user name, or any string that may contain spaces or special characters.
- Select encode-component: Choose 'encode-component' (encodeURIComponent). This encodes all characters that could be misread as URL structure, including &, =, ?, #, and spaces.
- Insert the result into your URL: Copy the encoded string and append it to your URL: ?key=<encoded-value>. The encoding table shows exactly which characters were changed so you can verify the output.
Frequently asked questions
- Do I need to encode the key name as well as the value?
- In practice, key names are usually simple ASCII strings with no special characters. But if your key name contains spaces or symbols, encode it with encodeURIComponent too — the same rules apply to both sides of the = sign.
- What happens if I don't encode the value?
- The browser or server will interpret special characters as URL delimiters. A & in the value will be parsed as a new parameter separator, splitting the value in two. A space will cause the URL to be truncated at that point.
Try it now
Use the URL Encoder / Decoder to complete this task — free, no sign-up, runs in your browser.
Open URL Encoder / Decoder →