How to encode a URL parameter
Percent-encode a query-string value so special characters do not break the URL. Step-by-step, plus the right function per language.
Putting a value with special characters into a query string can break the URL unless you percent-encode it. Here is how to encode a single parameter correctly — and the common mistake to avoid.
Encode the value, not the whole URL
Percent-encode each query-string value on its own, then assemble the URL. Characters like &, =, ?, #, and spaces would otherwise be read as structure rather than data. Encoding the entire URL instead would escape its own slashes and separators and break it.
The right function
In JavaScript use encodeURIComponent(value) for a single parameter (encodeURI is for a whole URL and leaves delimiters intact). Python: urllib.parse.quote(value). PHP: rawurlencode($value). Go: url.QueryEscape(value). Our URL tool does it interactively.
Step by step
Take the raw value (not the whole URL).
Percent-encode it — encodeURIComponent (JS), quote (Python), rawurlencode (PHP), or the URL tool.
Insert the encoded value into the query string.
Never encode the entire URL — that escapes its structural characters.
Try it now — free, no signup
Use the URL encoder in your browser. Then, when you need it at scale with an API key and higher limits, grab the full Eveses API.