How to URL Encode an Ampersand (& to %26)
The ampersand & in a URL becomes %26. This is necessary because & is a reserved character in URLs that separates query parameters (e.g., ?key1=val1&key2=val2). If the literal character & is part of a parameter value, it must be encoded as %26 to avoid being misinterpreted.
Example
If you want to search for "Tom & Jerry":
# Wrong — server sees two params: q=Tom, Jerry=
?q=Tom&Jerry
# Correct — server sees one param: q=Tom & Jerry
?q=Tom%26Jerry
Code Examples
JavaScript
encodeURIComponent('Tom & Jerry');
// "Tom%20%26%20Jerry"
Python
from urllib.parse import quote
quote('Tom & Jerry', safe='')
# 'Tom%20%26%20Jerry'
Also Remember: & in HTML
In HTML, use & to display a literal &. In URLs inside HTML attributes, you need both: href="?a=1&b=2".
Try It Yourself
Use our URL Encode & Decode tool to encode any string for URLs.
Frequently Asked Questions
What happens if I don't encode an ampersand in a URL?
The server will interpret & as a query parameter separator, splitting your value into two separate parameters. For example, ?q=Tom&Jerry creates parameter q=Tom and a separate parameter Jerry with no value.
What is the difference between %26 and &?
%26 is URL encoding for the ampersand character. & is the HTML entity for the ampersand. Use %26 in URLs and & in HTML source code.