What is Base64?
Base64 is an encoding scheme that converts binary or text data into a string of 64 printable ASCII characters. It is widely used to transmit data in email, embed images in HTML/CSS, and pass binary data through text-only channels. Decoding reverses the process back to the original text.
How do I encode text to Base64?
To encode text to Base64, take the raw bytes of the text, group them into sets of 3, and map each 3-byte (24-bit) group to four characters from the 64-character Base64 alphabet; short final groups are padded with =. Example: "hello" encodes to "aGVsbG8=" and decoding "aGVsbG8=" returns "hello".
Steps to encode and decode Base64
- Convert the input text to raw bytes using UTF-8 encoding.
- Group the bytes into sets of 3 (24 bits total) from left to right.
- Split each 24-bit group into four 6-bit chunks (values 0-63).
- Map each 6-bit chunk to one character in the Base64 alphabet A-Z, a-z, 0-9, +, /.
- If the final group has fewer than 3 bytes, pad the output with = characters so the total length is a multiple of 4; to decode, reverse each step to recover the original bytes.
Base64 encoding rule
3 bytes (24 bits) -> 4 Base64 characters (6 bits each), padded with = to a multiple of 4
- Base64 alphabet = A-Z, a-z, 0-9, +, / — 64 printable characters, each representing a value from 0 to 63
- = padding character fills an incomplete final group so encoded output length is always a multiple of 4
Example text-to-Base64 conversions
| Text | Base64 |
|---|
| a | YQ== |
| ab | YWI= |
| abc | YWJj |
| hello | aGVsbG8= |
| Hello, World! | SGVsbG8sIFdvcmxkIQ== |
Frequently asked questions
Is Base64 encoding the same as encryption?
No. Base64 has no secret key — anyone can decode it back to the original text using the same public, standardized alphabet. It only changes how data is represented for safe transmission through text-only systems; it provides no confidentiality and should never be used to protect sensitive data.
Why does encoded output sometimes end with = or ==?
The = characters are padding. Base64 always converts groups of 3 input bytes into 4 output characters; if the input length is not a multiple of 3, the last group is padded with one or two = signs so the total output length stays a multiple of 4.
Why is the Base64 output longer than the original text?
Each 3 bytes of input become 4 characters of output, so encoded text is roughly 33% larger than the original. This overhead is the tradeoff for representing arbitrary binary data using only safe, printable ASCII characters.
Can Base64 encode any type of data, not just text?
Yes. Base64 operates on raw bytes, so it can encode images, audio, or any binary file, not only text. This tool accepts text input and encodes its UTF-8 byte representation; encoding arbitrary binary files requires a tool that reads the file's bytes directly.
This tool encodes and decodes UTF-8 text entirely in your browser; it does not accept binary file uploads directly, and decoding text that is not valid Base64 shows an error rather than partial or corrupted output.
Sources: RFC 4648 - The Base16, Base32, and Base64 Data Encodings
Privacy and safety
- Runs in your browser — Everything you type is calculated on your own device. Your inputs are never sent to a utilduck server.
- Encrypted connection — Pages are served over HTTPS, so nobody on the network can read what you load.
- Not shared with third parties — Your inputs are not passed to analytics or advertising services.
- Nothing is stored — Results are not saved to any server, and there is no account to create.
Last updated: 2026-08-17