Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 back to text — with full Unicode support, so accented characters and emoji survive the round trip.
Base64 Encoder & Decoder
Your text is processed entirely in your browser — it is never sent to a server.
How it works:
Base64 takes 3 bytes (24 bits) at a time and splits them into 4 groups of 6 bits. Each 6-bit group becomes one character from A–Z, a–z, 0–9, + and /. A leftover of 1 or 2 bytes is padded with = so the output length is always a multiple of 4.
What Is Base64?
Base64 is a way of representing binary data as plain text. It takes any bytes — text, an image, a file — and rewrites them using only 64 safe characters: the letters A to Z, a to z, the digits 0 to 9, plus (+), and slash (/), with equals (=) as padding. The result is longer than the original by about a third, but it is made entirely of characters that survive email, URLs, JSON, and every other text-based system without being mangled.
That safety is the whole point. Binary data contains bytes that many systems treat specially: a zero byte ends a string in C, a newline splits a line, a quote closes a field. Base64 sidesteps all of that by translating the data into an alphabet that no text system will misread. The translation is fully reversible — decoding the Base64 gives back the exact original bytes — so it is used everywhere data has to travel through a text-only channel.
How to Use This Encoder
Type or paste text and choose Encode to get its Base64 form, or paste Base64 and choose Decode to get the original text back. The result updates as you type, and the length line shows how many characters went in and came out. Switching modes converts in the other direction, so you can encode a message, copy the output, and decode it again to check the round trip.
The encoder handles Unicode correctly. Many simple Base64 tools break on accented characters, Chinese text, or emoji, because they pass the raw string to the browser's built-in encoder, which only understands Latin-1 characters. This tool converts the text to UTF-8 bytes first, then encodes those bytes — so "café ☕" encodes to "Y2Fmw6kg4piV" and decodes back to "café ☕" exactly. Everything runs in your browser: the text you paste is never sent to a server.
How Base64 Encoding Works
Base64 works in groups of three bytes. Three bytes are 24 bits, and 24 divides evenly by 6, so each group becomes four 6-bit numbers. Each 6-bit number (0 to 63) maps to one character in the Base64 alphabet: 0–25 are A–Z, 26–51 are a–z, 52–61 are 0–9, 62 is +, and 63 is /. Three input bytes always become four output characters, which is why Base64 output is 4/3 the size of the input — about 33% larger.
When the input length is not a multiple of three, padding fills the gap. One leftover byte becomes two Base64 characters plus "==" padding; two leftover bytes become three characters plus "=" padding. That is why "Hello" (5 bytes) encodes to "SGVsbG8=" — the first three bytes, "Hel", become "SGVs", and the remaining two bytes, "lo", become "bG8=" with one padding character. The padding also tells the decoder exactly how many bytes to expect, so decoding is unambiguous.
The size overhead is predictable: 3 bytes become 4 characters, 1,000 bytes become 1,336 characters (1,000 divided by 3 rounds up to 334 groups, times 4), and 1 megabyte becomes about 1.37 megabytes. That overhead is the price of text safety, and it is why Base64 is used for small payloads — tokens, images in emails, data URLs — rather than for bulk file transfer, where the 33% tax adds up.
Where Base64 Is Used
Email attachments. Email was designed for text, so attachments are Base64-encoded into the message body (MIME encoding). A 3 MB photo attached to an email travels as about 4 MB of Base64 text, which is why attachments make messages noticeably larger than the file itself.
Data URLs. A small image can be embedded directly in a web page or stylesheet as a data URL — data:image/png;base64,... — instead of being loaded as a separate file. This saves a network request for tiny icons and logos, at the cost of the 33% size overhead.
API tokens and basic authentication. HTTP Basic Auth sends a username and password as a single Base64 string in a header. JSON Web Tokens (JWTs) use a URL-safe variant of Base64 for their three parts. In both cases the encoding is for transport, not security — anyone can decode Base64, so it must always travel over an encrypted connection.
Embedding binary data in JSON and XML. JSON strings cannot hold raw bytes, so binary fields — a file upload, a cryptographic signature, a thumbnail — are Base64-encoded into the JSON string. The receiving side decodes them back to bytes before use.
Base64 Is Not Encryption
This is the most important thing to understand about Base64: it is an encoding, not encryption. Encoding changes the representation of data; encryption changes who can read it. Anyone who sees a Base64 string can decode it in seconds with a tool like this one — there is no key, no secret, and no protection. Encoding a password in Base64 does not hide it; it just makes it look scrambled to a casual glance.
Base64 has its place — safe transport through text systems — but it must never be the only protection for sensitive data. Passwords should be hashed, secrets should be encrypted with a real cipher and a key, and anything sent over a network should travel over HTTPS. If you find yourself encoding something "so nobody can read it", stop: what you need is encryption, not Base64.
Tips for Working with Base64
Check the padding. Valid Base64 has a length that is a multiple of 4, with zero, one, or two "=" characters at the end. If a string's length is not a multiple of 4, or it has padding in the middle, it has been truncated or corrupted — often by a line break or a copy-paste error. This decoder rejects such input rather than guessing.
Watch for the URL-safe variant. Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe variant replaces them with - and _ and often drops the padding. If a token from a URL fails to decode here, try replacing - with + and _ with /, and adding "=" padding until the length is a multiple of 4.
Remember the 33% overhead. When estimating storage or bandwidth for Base64 data, multiply the original size by 4/3. A 3 MB file needs 4 MB of Base64; a database column sized for the raw bytes will overflow if it stores the encoded form.
Test the round trip. Encode, then decode, and compare with the original — especially for non-English text. If accented characters or emoji come back wrong, the tool that encoded them did not handle UTF-8 properly. This tool encodes to UTF-8 first, so the round trip is exact.
Common Mistakes to Avoid
The most common mistake is treating Base64 as security, covered above: it hides nothing. The second is using the browser's raw btoa on a Unicode string, which throws an error or mangles the text, because btoa only accepts characters in the Latin-1 range. The fix is to convert the string to UTF-8 bytes first — which is what this tool does — and to convert back with a UTF-8 decoder when decoding.
Another frequent error is copying Base64 with line breaks or spaces in it. Encoders often wrap output at 76 characters per line (the MIME standard), and pasting the wrapped text into a decoder that does not strip whitespace fails. This decoder ignores whitespace, so wrapped Base64 pastes cleanly — but if another tool rejects your Base64, stripping the line breaks is the first thing to try.
Finally, do not confuse Base64 with hexadecimal. Hex encoding uses 16 characters (0–9, a–f) and doubles the size; Base64 uses 64 characters and grows the data by a third. A hash shown as hex (like an MD5 checksum) is not Base64, and decoding it as Base64 produces garbage. For structured data, see the JSON formatter and the CSV to JSON converter.
Frequently Asked Questions
What is Base64 used for?
Base64 represents binary data as plain text so it can travel through text-only systems: email attachments, data URLs, API tokens, and binary fields inside JSON. It is fully reversible — decoding gives back the exact original bytes.
Is Base64 encryption?
No. Base64 is an encoding, not encryption — anyone can decode a Base64 string with no key. It hides nothing. Use real encryption (and HTTPS) for sensitive data; Base64 only makes data safe to transport as text.
Why is Base64 output longer than the input?
Base64 turns every 3 bytes into 4 characters, so the output is 4/3 the size of the input — about 33% larger. 1,000 bytes become 1,336 characters, and 3 MB becomes about 4 MB.
Why does my Base64 end with = signs?
The = signs are padding. Base64 works in groups of 3 bytes; a leftover of 1 byte gets == and a leftover of 2 bytes gets =. The padding keeps the output length a multiple of 4 and tells the decoder how many bytes to expect.
Does this tool handle emoji and accented characters?
Yes. The text is converted to UTF-8 bytes before encoding, so café ☕ encodes to Y2Fmw6kg4piV and decodes back exactly. Simple tools that use raw btoa on Unicode text mangle these characters.