A value comes back from an API covered in percent signs, and another one arrives as a block of letters ending in equals signs. Both look scrambled, both get called "encoded", and developers reach for whichever decoder is nearest. That guesswork causes real bugs, because URL encoding and Base64 encoding do different jobs. One makes text safe inside a web address. The other carries data through channels that only handle plain text.
This guide compares the two side by side, using the free URL Encoder/Decoder on Ovatly for the percent-encoding side, so you can pick the right one first time and recognise the wrong one on sight.
Contents
- Quick answer
- The two jobs, in plain terms
- How the alphabets and overheads differ
- How to encode a value for a URL, step by step
- Worked example: one phrase, two encodings
- Limitations and honest warnings
- Common mistakes
- FAQs
- Conclusion
Quick answer
Use URL encoding when the destination is a web address: a query value, a redirect target, or a whole address with a stray space in it. Use Base64 when the destination is a text-only channel such as JSON, email or a data URI, and the data needs to survive the trip unchanged. If the text needs to stay human-readable inside the address, it is URL encoding. If the text is a payload being carried, it is probably Base64. Neither one hides anything from anyone.
The two jobs, in plain terms
A URL is a structured string. The ? starts the query string, each & starts a new parameter, = separates a name from its value, and / separates path segments. That structure is exactly why raw text breaks addresses. Put the search phrase "fish & chips" into a query string without encoding and the ampersand starts a second parameter that nobody intended. URL encoding fixes this by replacing characters that a URL cannot carry raw with percent codes, so the structure characters keep their meaning and the data characters lose theirs.
Base64 solves a transport problem instead. Some channels can only carry plain text safely: JSON documents, email and data URIs are the examples named by the Base64 Text Encoder/Decoder. Raw bytes get mangled or rejected on those channels, so Base64 represents the data using only letters, digits and a few safe symbols. The output is not meant to sit inside an address or be read by a person. It is meant to arrive intact and be decoded at the other end.
The practical test is the destination. Ask where the encoded text has to live. Inside an address, surrounded by structure that must keep working, the answer is URL encoding. Inside a JSON field, an email body or an embedded asset, the answer is Base64.
How the alphabets and overheads differ
URL encoding is surgical. Characters that are safe in a URL pass through unchanged, letter for letter, and only the unsafe ones are replaced, each by a percent sign followed by two hexadecimal digits. A space becomes %20, an ampersand becomes %26, a slash becomes %2F. That is why a mostly ordinary phrase stays mostly readable after URL encoding, and why the size cost depends entirely on how many unsafe characters the text contains. Text with no unsafe characters does not grow at all. Text full of spaces and symbols grows by two extra characters for each one replaced, and non-ASCII characters cost more still, because they are encoded as their UTF-8 bytes: one accented letter becomes two percent codes, six characters in total.
Base64 is wholesale. Every character of the input is transformed, readable or not, using a 64-character alphabet of letters, digits and a few symbols, working in groups of four characters with = padding marking the final partial group. Nothing of the original wording survives on the surface. The cost is predictable instead of variable: the output is about a third larger than the input, every time, whatever the input contains.
Those two profiles explain the shapes you see in the wild. A long value that still reads as broken English with percent signs scattered through it is URL-encoded. A dense block of mixed-case letters and digits, with no spaces and maybe an equals sign or two at the end, is Base64.
How to encode a value for a URL, step by step
- Open the URL Encoder/Decoder.
- Choose Component mode for a single value going into a query string, or Full URL mode for a whole address. Component mode encodes everything a URL cannot carry raw, including
&,=,?and/. Full URL mode encodes spaces and stray characters while deliberately leaving the structural characters alone, so the address keeps working. - Paste your text or URL.
- Press Encode or Decode.
- Copy the result. Decoding runs the same way in reverse, and invalid input, like a stray
%or an incomplete%2at the end, produces a clear error instead of garbage.
Worked example: one phrase, two encodings
Take the phrase "hello world & more", the example used by the tool itself. It is 18 characters long, and it contains two kinds of trouble for a URL: spaces, and an ampersand that a query string would read as a parameter separator.
Encoded for a URL in component mode, it becomes:
hello%20world%20%26%20more
That is 26 characters. The words survived untouched, each space became %20, and the ampersand became %26, so the whole phrase can now sit inside a query string as one value. Encoded as Base64 instead, the same phrase becomes:
aGVsbG8gd29ybGQgJiBtb3Jl
That is 24 characters, about a third larger than the original 18, exactly the overhead Base64 always charges. Nothing in it is readable, and nothing in it knows it was ever a phrase. Put that string in a query string and the receiving side gets an opaque payload it must Base64-decode before the words appear. Both outputs are correct encodings. Only the first one is correct for an address.
Limitations and honest warnings
Neither encoding is encryption, and this is the warning that matters most. Percent codes and Base64 are fixed public recipes with no key and no secret step. Anyone who sees the output can reverse it with the same free tools, in seconds. An encoded password, token or personal detail is a readable password, token or personal detail. Never use either encoding to protect anything.
URL encoding also has a scope limit: it makes text safe for an address, and nothing more. It does not validate the address, fix a broken link, or make a value safe in other contexts such as HTML. And Base64 has a direction limit worth remembering: the standard alphabet includes characters that clash with URL structure, which is why the URL-safe variant, swapping in - and _, exists for the cases where Base64 output genuinely has to travel inside an address.
Common mistakes
- Base64-encoding a query value. The result is an opaque payload where a readable value belonged, and it still may contain characters that clash with the address.
- URL-encoding a whole payload. Percent-encoding a JSON blob or file content triples every unsafe character and produces something no receiving system expects.
- Encoding a whole address in component mode. Component mode encodes the structural characters too, including
/and?, which destroys the address. Whole addresses belong in Full URL mode. - Treating either output as hidden. Encoded is not protected. If a value is secret, it needs real encryption or a proper hash, not an encoding.
- Decoding something twice, or not at all. A value that was encoded once and decoded twice, or passed along still encoded, shows up as percent signs and equals signs in the wrong places. Match the decode count to the encode count.
FAQs
Which encoding do I need for a search term inside a URL?
URL encoding, in component mode. A search term is a single value inside a query string, so characters like &, = and ? inside the term itself must be encoded or they will be read as URL structure.
Can Base64 text go inside a URL?
Standard Base64 uses characters that clash with URL structure, which is why a URL-safe variant exists that swaps in - and _. Even then, Base64 inside a URL is for carrying data, not for making a normal address value readable.
Is either of these encodings a form of encryption? No. Both are fixed, public recipes with no key. Anyone can decode a percent-encoded string or a Base64 string with the same tools you used to encode it.
Why does URL-encoded text get longer?
Each unsafe character becomes three characters, like %20 for a space. Non-ASCII characters take even more, since they are encoded as their UTF-8 bytes, so one accented letter becomes two percent codes.
Is + the same as %20 in a URL?
In query strings produced by form submissions, + means a space. The URL Encoder/Decoder uses %20, which is valid everywhere in a URL, to avoid ambiguity.
Conclusion
Pick by destination: URL encoding for text that must live inside an address, Base64 for data that must travel through a text-only channel, and neither for anything that needs to stay secret. The percent codes scattered through an address have their own reading rules, covered in Why Does My URL Show %20 and %2F? Decoding Explained. For more tools like these, see the Developer Tools guide archive.