Base64 & URL Encoder/Decoder

The Base64 & URL Encoding Guide

What Base64 and URL (percent) encoding actually are, why they exist, when to use which, and where each one shows up in real-world development.

Open Base64 & URL Tool

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

 Base64URL Encoding
PurposeRepresent binary or arbitrary data as compact printable textMake text safe to place inside a URL
Alphabet usedA-Z, a-z, 0-9, +, / (plus = padding)Original ASCII characters, with unsafe ones replaced by %XX
Typical size change~33% larger than inputVaries - only unsafe characters grow (each becomes 3 characters)
Common useData URIs, Basic Auth headers, embedding binary in JSON/XMLQuery string values, path segments, form submissions
Reversible without a key?Yes, instantlyYes, instantly

Common Use Cases

Data URIsEmbed a small image or font directly in CSS/HTML as a Base64-encoded data URI, avoiding an extra network request.
API Auth HeadersHTTP Basic Auth Base64-encodes a "username:password" pair before sending it in the Authorization header - not encryption, so it must be paired with HTTPS.
Query String EncodingURL-encode a value before appending it to a query string so spaces, symbols, and non-ASCII characters don't break the link.
Passing Binary Through Text FieldsBase64-encode binary data (like a small file) so it can travel safely inside JSON, XML, or a text-only form field.

Frequently Asked Questions

Is Base64 encoding a form of encryption?

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.

What's the difference between encodeURIComponent() and encodeURI()?

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.

Why does Base64 output sometimes end with one or two "=" signs?

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.

Why do Basic Auth headers Base64-encode credentials instead of sending them as plain text?

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.

Why do characters like & and = need to be escaped inside a URL value?

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.

Open Base64 & URL Tool