Practical tool guide · Published

How to URL-Encode Query Parameters Without Breaking Links

Encoding the wrong part of a URL is a common cause of broken filters, search links and tracking parameters. Learn which characters belong to a value and which must remain as URL syntax.

Illustrated example for URL Encoder: red & blue compared with red%20%26%20blue
Example workflow for URL Encoder: url components with sample input and result.
Quick answer

Encode each query value separately with URL Encoder, then add the encoded value after the parameter name. Do not encode the entire URL as one component. Try URL Encoder.

Know which characters have a structural role

In a URL such as /search?q=red%20%26%20blue, the question mark introduces the query and the equals sign separates its key from its value. The ampersand normally separates multiple parameters. If you want an ampersand inside the search phrase, it must be encoded as %26.

The browser tool uses encodeURIComponent on a single component. Spaces become %20, an internal slash becomes %2F, and Unicode characters are percent-encoded from UTF-8 bytes. Encoding the full https:// URL would also encode its colons and slashes, making it unusable as an address.

Build a query string reliably

Start with the raw value, for example red & blue. Encode only that value to red%20%26%20blue. Then build /search?q=red%20%26%20blue. If there are multiple parameters, encode each name and value separately before combining them with the URL's separators.

In application code, prefer URLSearchParams where available because it handles assembling parameters and escaping. Note that form-style serialization often uses + for spaces, while the component encoder shown here produces %20.

  • Test the full URL in the destination application.
  • Avoid manually double-encoding existing percent sequences.

Non-ASCII text and round-trip checks

A word such as café is encoded using UTF-8 bytes rather than a single legacy code-page byte. This matters when sharing multilingual links across browsers and servers.

Decode the generated component with URL Decoder and compare it with your original. A decoded + remains a plus with this tool; it is not automatically a space. If you are working with application/x-www-form-urlencoded data, use the form encoding rules instead.

Where encoding still goes wrong

A value that is already percent-encoded can become double encoded: the percent character in %20 becomes %25, producing %2520. Decide whether your input is raw text or an already-encoded component before applying the operation.

URL encoding does not validate that a destination is trustworthy, nor does it make an unsafe URL safe to open. Always validate untrusted destinations and avoid embedding credentials or secrets in query strings where browser history and logs may preserve them.

Common questions

Should I encode a full URL?

Not with a component encoder; it would escape separators such as : and /.

Why do some forms use + instead of %20?

Form-style query encoding has different space-handling conventions from encodeURIComponent.