URL encoder/decoder · Guide
URL Encoding Ampersand: Escaping & and @ in Query Strings
The ampersand separates query parameters, so an unescaped `&` inside a value ends that value and starts a new parameter. It is the single most common URL encoding bug and it fails silently — you get a truncated value, not an error.
What goes wrong
A search for "salt & pepper" naively becomes ?q=salt & pepper. The server parses q=salt and a second parameter named pepper, so the search runs for "salt" and nobody notices until someone reports odd results.
Encoded properly it is ?q=salt%20%26%20pepper — %26 is the ampersand, and the whole string arrives as one value.
The at sign
@ is reserved because it separates userinfo from host in a URL. Inside a path segment or a query value it should be %40.
In practice most servers accept a literal @ in a query string, which is why ?email=user@example.com usually works. "Usually" is the problem: a strict parser, a signature check or a proxy may disagree, so encode it and remove the question.
URL encoding is not HTML escaping
These two get confused constantly because both deal with ampersands. In a URL, & becomes %26. In HTML, & becomes &. They are different layers solving different problems.
When a URL appears inside an HTML attribute, both apply — first URL-encode the values, then HTML-escape the resulting URL:
<!-- value URL-encoded, then the whole href HTML-escaped -->
<a href="/search?q=salt%20%26%20pepper&page=2">results</a>Seeing & in an actual HTTP request means the HTML escaping leaked into the URL — the browser should have decoded it back to & before sending.
Frequently asked questions
How do I encode an ampersand in a URL?
As %26, using encodeURIComponent or rawurlencode on the value.
Do I need to encode @ in an email query parameter?
Most servers tolerate it, but %40 is correct and avoids edge cases with strict parsers and signatures.
Should a URL contain &?
Only inside HTML source. The request itself carries a plain &.
Ready to try it?
Open the free browser-based URL encoder/decoder and apply what you just read — no sign-up, runs locally.
Open the URL encoder/decoder tool