%url-decoder.net

URL Encoding vs HTML Encoding vs Base64

Updated November 18, 2026 · 5 min read

Short answer

URL encoding (%26) makes text safe inside a URL, HTML encoding (&) makes text safe inside an HTML page, and Base64 turns any bytes into plain letters and digits. They solve different problems, use different decoders, and are not interchangeable: %26 in HTML text is just the characters %, 2 and 6.

Search results for “html url encoding” mix three different things. Each one makes text safe for a different place, and using the wrong one leaves the text either broken or double-escaped. Here is how to tell them apart.

Side by side

The same text, encoded three ways. URL encoding uses encodeURIComponent, HTML encoding uses this site's HTML encoder, and Base64 encodes the UTF-8 bytes. All values were produced by running the code.

TextURL encodingHTML encodingBase64
Tom & JerryTom%20%26%20JerryTom & JerryVG9tICYgSmVycnk=
<b>%3Cb%3E&lt;b&gt;PGI+
"quoted"%22quoted%22&quot;quoted&quot;InF1b3RlZCI=
50% off50%25%20off50% offNTAlIG9mZg==
cafécaf%C3%A9caféY2Fmw6k=

What each one is for

  • URL encoding (percent-encoding) protects data inside a URL. Characters with a job in URL syntax, such as &, = and ?, and characters a URL cannot hold, such as spaces, become %XX. Decoded by URL parsers and servers. URL Encoder.
  • HTML encoding (character references) protects text inside an HTML document. <, > and & become &lt;, &gt; and &amp; so they are shown as text instead of being read as markup. Decoded by the HTML parser. HTML Encoder.
  • Base64 turns arbitrary bytes into 64 safe characters so binary data can travel through text-only channels. Output grows by about a third. Not a form of encryption. Base64 tool.

Links in HTML need two layers

A link to a search for Tom & Jerry written into a web page goes through both encodings, in this order:

  1. Percent-encode the value: Tom%20%26%20Jerry
  2. Build the URL: /search?q=Tom%20%26%20Jerry&page=2
  3. HTML-escape it for the attribute: /search?q=Tom%20%26%20Jerry&amp;page=2

The browser reverses the steps: the HTML parser turns &amp; back into &, and the server later decodes %26. Skipping step 1 cuts the value at the ampersand. Skipping step 3 is usually tolerated by browsers, but it is invalid HTML and can be misread.

Common mix-ups

  • &amp; inside a decoded URL. The URL was HTML-escaped twice, or copied from HTML source. Decode it with the HTML decoder, not the URL decoder.
  • %20 showing up on a page. A URL-encoded value was displayed as text without being decoded first.
  • Base64 in a URL losing characters. Standard Base64 uses + and /, which have meaning in URLs. Use Base64URL or percent-encode the value; see %2B.

Questions

Is %26 the same as &amp;?

Both stand for an ampersand, but in different languages. %26 is decoded by URL parsers, &amp; by HTML parsers. Use %26 inside a URL's data and &amp; when writing an ampersand in HTML source, including inside an href attribute.

Do I need both URL and HTML encoding for a link in a web page?

Often, yes. First percent-encode each value that goes into the URL, then HTML-escape the finished URL when you write it into an HTML attribute. The browser undoes the HTML escaping first and the URL encoding later.

Is %20 the same as &nbsp;?

No. %20 is an ordinary space inside a URL. &nbsp; is a non-breaking space (U+00A0) in HTML text, a different character. Percent-encoded, a non-breaking space is %C2%A0.

When should I use Base64 instead of URL encoding?

Use Base64 for binary data, such as images or keys, that must travel as text. For ordinary text in a URL, percent-encoding is shorter and stays readable. If Base64 goes into a URL, use the URL-safe variant, which replaces + and / with - and _.

See also

Try everything in this guide hands-on, free and entirely in your browser.

Open the URL Encoder

Keep reading