How Base64 encoding works
Base64 is a way of representing any data, text, images, or raw bytes, using a small set of printable characters. Many systems (email, URLs, JSON, older network protocols) were built to carry plain text and can choke on arbitrary bytes. Base64 sidesteps that by rewriting the data in a form that survives text-only channels intact. This tool converts in both directions, all in your browser.
What Base64 is and its 64-character alphabet
The name says it: Base64 uses 64 distinct characters to stand in for data. The standard alphabet is the 26 uppercase letters A to Z, the 26 lowercase letters a to z, the 10 digits 0 to 9, and two symbols, + and /. That is 64 characters, and each one represents a 6-bit value from 0 to 63.
Because bytes are 8 bits and Base64 characters are 6 bits, the two do not line up evenly. Base64 solves this by working in blocks: three bytes (24 bits) become exactly four Base64 characters (4 x 6 = 24 bits). When the input does not end on a clean three-byte boundary, the encoder pads the output with one or two = signs so the result is always a whole number of four-character blocks.
How 3 bytes map to 4 characters
The core trick is regrouping bits. Take three bytes, line up their 24 bits in a row, then slice that row into four groups of 6 bits instead of three groups of 8. Each 6-bit group is a number from 0 to 63, and you look it up in the alphabet above.
- Three input bytes produce four characters with no padding.
- Two input bytes (16 bits) produce three characters plus one
=. - One input byte (8 bits) produces two characters plus two
=.
That padding is why Base64 output length is always a multiple of four, and why short inputs end in =.
A worked example: βManβ to βTWFuβ
Take the three letters Man. Their byte values are 77, 97, and 110.
- Write each byte in 8-bit binary:
01001101(77),01100001(97),01101110(110). - Join into a 24-bit row:
010011010110000101101110. - Re-slice into four 6-bit groups:
010011010110000101101110. - Read each group as a number: 19, 22, 5, 46.
- Look up the alphabet: 19 is
T, 22 isW, 5 isF, 46 isu.
So Man becomes TWFu, with no padding because three bytes filled the block exactly. Shorter inputs like Hi (two bytes) round out to SGk=, and Hello, World! (13 bytes) needs two padding signs, giving SGVsbG8sIFdvcmxkIQ==.
Encoding is not encryption
This is the most important caveat. Base64 is not encryption and offers no security. There is no key and no secret step. Anyone who sees a Base64 string can decode it instantly, exactly as this tool does. Its job is safe transport of data through text channels, not confidentiality. If you need to protect data, use real encryption; Base64 on top of that is fine, but Base64 alone hides nothing.
UTF-8 and Unicode handling
Base64 works on bytes, not letters, so the first step for text is deciding how letters become bytes. This tool uses UTF-8, the standard modern encoding. Plain English characters take one byte each, while accented letters take two and most emoji take four. The converter turns your text into UTF-8 bytes first, then Base64-encodes those bytes, so accented text and emoji round-trip perfectly. On decode it reverses both steps, rebuilding the exact original characters.
Common uses
Base64 shows up all over software:
- Data URIs: small images and fonts can be embedded directly in HTML or CSS as
data:image/png;base64,..., saving a network request. - Email attachments: the MIME standard uses Base64 to send binary files (images, PDFs) through email, which was designed for text.
- APIs and tokens: JSON Web Tokens (JWTs) and many API payloads use Base64 (often the URL-safe variant) to package data compactly in text.
- Config and storage: binary blobs such as keys or certificates are frequently stored as Base64 strings inside JSON, YAML, or environment variables.
In short, reach for Base64 whenever binary data needs to travel through something that expects plain text. Just remember it is a representation, not a lock.