A clear explanation of Base64 encoding — what it is, why it exists, and how the encoding algorithm works step by step.
Binary data (images, files, keys) can contain any byte value (0–255). Many protocols — email (SMTP), HTTP headers, JSON — are designed for text and can't safely carry arbitrary binary.
Base64 solves this by encoding binary into a subset of ASCII characters that are safe to transmit anywhere.
Base64 uses 64 characters: A–Z (26), a–z (26), 0–9 (10), + and / (2). Each character represents 6 bits of data. Three bytes (24 bits) → four Base64 characters.
Take the string Man:
01001101 01100001 01101110010011 010110 000101 101110T, W, F, u → TWFubtoa("Man") // "TWFu"
atob("TWFu") // "Man"
If the input isn't divisible by 3 bytes, = padding is added:
===Standard Base64 uses + and / which are special in URLs. Base64URL replaces them:
| Standard | Base64URL |
|---|---|
+ | - |
/ | _ |
JWTs use Base64URL encoding.
Note: Base64 is encoding, not encryption. Anyone can decode it.
Try the Base64 Encoder/Decoder to convert data instantly.