Cadmeo

Base64 Encoder vs URL Encoder

Choose this if

Base64 Encoder and Decoder

you need to carry binary data, or arbitrary bytes, through something that only handles text

Choose this if

URL Encoder and Decoder

you need to put a value into a URL without its special characters breaking the URL

How they compare

Base64 Encoder and Decoder compared with URL Encoder and Decoder, criterion by criterion
CriterionBase64 Encoder and DecoderURL Encoder and Decoder
The problem it solvesSystems that only accept printable text cannot carry raw bytesCharacters like &, ? and / already mean something structural inside a URL
Size changeGrows by about a third: every three bytes become four charactersGrows only for the characters that need escaping, each becoming three charactersBetter here
Output alphabetA-Z, a-z, 0-9, plus + / and =: two of which are themselves unsafe in a URLThe original text with unsafe characters replaced by %XX
Readability of the resultNone. The output bears no visible relation to the inputLargely preserved: "hello world" stays legible as "hello%20world"Better here
Safe in a URL as-isNo, unless you use the URL-safe alphabet, which substitutes - and _ and drops the paddingYes: that is precisely what it is forBetter here

Which is best for you

Use Base64 when the payload is not text

Embedding an image in a data URI, attaching a file to an email, putting a binary blob in a JSON field, carrying a signature in a token. All of these need bytes to survive a text-only channel. Base64 is the standard answer. Remember it is an encoding and not encryption: anyone holding the string can read it back in seconds.

Use percent-encoding when you are building a URL

Any value going into a query parameter or a path segment needs escaping, and the mode matters. Component encoding escapes everything reserved and is what a single value needs. Whole-URL encoding leaves the structural characters alone. Getting this wrong is why a redirect parameter containing its own query string loses everything after the first ampersand.

The recommendation

These are not alternatives and picking between them is usually a sign the question is wrong. Ask what you are protecting against: if the data is not text, Base64 it; if the data is text going into a URL, percent-encode it. The one case where both apply is putting binary into a URL, and then you Base64 it with the URL-safe alphabet, which is exactly what a JWT does, and why its segments contain no plus signs or slashes.

Frequently asked questions

Can I put a Base64 string straight into a URL?

Not standard Base64. It uses + and / which are reserved in URLs, and = which is awkward in a query string. Use the URL-safe variant, which substitutes - and _ and drops the padding. Every Base64 tool worth using offers it, and JWTs rely on it.

Is either of these a form of security?

Neither. Both are reversible with no key at all. A password Base64-encoded in a config file is stored in plain text for every practical purpose, and percent-encoding hides nothing whatsoever. If you need the content protected, you need encryption, which is a different thing entirely.

Why did my URL break after I encoded it?

Almost certainly component encoding applied to a whole URL, which escapes the colon and the slashes and leaves you with something that is no longer a URL. Component encoding is for one value; whole-URL encoding is for a complete address.

Both tools