What Is Base64 Encoding?
Base64 is a way of representing binary or text data using only 64 printable ASCII characters (A-Z, a-z, 0-9, + and /). It exists because many older systems and text-based formats - email, JSON, XML, HTTP headers - were designed to carry plain text safely, but not arbitrary binary bytes. Base64 re-encodes any data into a text-safe format that survives being copied, emailed, or embedded without corruption.
Every 3 bytes of input become 4 Base64 characters, which is why Base64 output is roughly 33% larger than the original data. It is not compression and not encryption - it's purely a representation change, and it's trivially reversible by anyone with no key required.
What Is URL Encoding?
URL encoding, also called percent-encoding, converts characters that aren't safe or allowed inside a URL - spaces, ampersands, slashes, quotes, non-ASCII letters, and more - into a %XX sequence, where XX is the character's hex byte value. It exists because a URL's own syntax uses reserved characters like &, =, ?, and / to separate its parts, so any of those characters appearing inside a value has to be escaped or it will be misread as part of the URL's structure.
For example, a space becomes %20 and an & becomes %26, so a value like tom & jerry can safely travel as a single query parameter without breaking the link.
Base64 vs URL Encoding - When to Use Which
| Base64 | URL Encoding | |
|---|---|---|
| Purpose | Represent binary or arbitrary data as compact printable text | Make text safe to place inside a URL |
| Alphabet used | A-Z, a-z, 0-9, +, / (plus = padding) | Original ASCII characters, with unsafe ones replaced by %XX |
| Typical size change | ~33% larger than input | Varies - only unsafe characters grow (each becomes 3 characters) |
| Common use | Data URIs, Basic Auth headers, embedding binary in JSON/XML | Query string values, path segments, form submissions |
| Reversible without a key? | Yes, instantly | Yes, instantly |
Common Use Cases
Frequently Asked Questions
No. Base64 is reversible with no key required - anyone can decode it instantly. It only changes the representation of data, not its security. Never use Base64 alone to protect sensitive information.
encodeURI() is meant for encoding a whole URL, so it leaves structural characters like :, /, ?, and & untouched since they're part of the URL's own syntax. encodeURIComponent() is meant for encoding a single value that will be placed inside a URL, such as a query parameter, so it escapes those same reserved characters too. This tool's URL mode encodes values the way encodeURIComponent() does, since its job is encoding a piece of data, not a full URL.
Base64 converts data 3 bytes at a time into 4 characters. When the input length isn't a multiple of 3, the final group has only 1 or 2 bytes left over, so it gets padded with "=" characters to keep the output length a multiple of 4 - one leftover byte adds "==", two leftover bytes add a single "=". If the input length divides evenly by 3, there's no padding at all.
Mainly because HTTP headers weren't designed to safely carry arbitrary characters, and a raw "username:password" could contain the header's own separator or non-ASCII bytes. Base64-encoding the pair guarantees the result is plain ASCII text that survives any HTTP transport unmodified. It is not encryption or hashing - anyone can decode it instantly - which is exactly why Basic Auth must always be sent over HTTPS.
In a URL's query string, & separates one parameter from the next and = separates a parameter's name from its value - that's the query string's own syntax. If a value itself contains an unescaped & or =, the parser misreads where one parameter ends and the next begins. Percent-encoding turns them into %26 and %3D so they're treated as literal characters inside the value rather than as query-string structure.