Formula
every 3 bytes (24 bits) → 4 characters of 6 bits each from a 64-character alphabet
- Text is first converted to bytes with UTF-8.
- = padding fills the last group when the length isn't a multiple of 3.
Base64 re-writes bytes using only letters, digits and two symbols so they survive text-only channels.
Worked example
Encode a greeting
- Direction
- Encode text → Base64
- Alphabet
- Standard (+ / with = padding)
- Input
- Hello, world!
Base64
SGVsbG8sIHdvcmxkIQ==
Input size: 13 bytes
Output size: 20 characters
SGVsbG8sIHdvcmxkIQ==
How it works
Base64 turns binary data into plain ASCII: each group of 3 bytes becomes 4 characters, so the output is about a third larger. It is used in email attachments, data URLs, HTTP basic authentication and JSON Web Tokens. It is an encoding, not encryption — anyone can decode it.
Text is converted to UTF-8 bytes first, so “héllo 🌍” round-trips correctly, which the browser's built-in btoa() cannot do. The URL-safe variant swaps + and / for - and _ so the result can sit inside a URL or filename. When decoding, line breaks are ignored and missing padding is tolerated; if the bytes aren't text (an image, say) the tool tells you instead of printing garbage. See also URL Encode and Decode and JWT Decoder, which uses Base64URL.
Assumptions and limits
- Input is limited to 2 million characters.