A base64 encoder decoder converts text to base64, a form that uses only letters, digits, + and /, and turns base64 back into the original text. “Hello” encodes to SGVsbG8= and “Man” to TWFu.
On this page

How to use the base64 encoder decoder
- Type or paste your text, or a base64 string to decode.
- Choose Encode or Decode.
- Copy the result.
How the base64 encoder decoder works
Base64 turns bytes into text that uses only 64 safe characters: A–Z, a–z, 0–9, + and /. The text is first converted to bytes with UTF-8. Every group of 3 bytes (24 bits) is split into four 6-bit pieces, and each piece picks one character from the alphabet. When the last group has only one or two bytes, the output is padded with one or two = signs so its length is a multiple of four. Decoding reverses the steps.
- 3 bytes in → 4 characters out
- Encoded size ≈ 4 × ceil(bytes ÷ 3) characters, about 33% larger
- = at the end is padding, not data
Base64 encoder decoder worked example
| Input | Base64 | Notes |
|---|---|---|
| M | TQ== | 1 byte → 2 characters + 2 padding |
| Ma | TWE= | 2 bytes → 3 characters + 1 padding |
| Man | TWFu | 3 bytes → 4 characters, no padding |
| Hello | SGVsbG8= | 5 bytes → 8 characters |
| café | Y2Fmw6k= | é is 2 bytes in UTF-8 |
| Hello Multicalify | SGVsbG8gTXVsdGljYWxpZnk= | 17 bytes → 24 characters |
“Man” is the three bytes 77, 97 and 110. In binary that is 01001101 01100001 01101110. Regrouped into 6-bit pieces it becomes 010011 010110 000101 101110, which are 19, 22, 5 and 46, the characters T, W, F and u. So “Man” encodes to TWFu, and decoding TWFu gives back “Man”.
Where base64 is used
- Email attachments: MIME uses base64 to send files through systems built for text.
- Data URLs: small images can be embedded in HTML or CSS as data:image/png;base64,…
- APIs and tokens: JSON Web Tokens use the URL-safe variant, and HTTP Basic authentication sends user:password in base64.
- Configuration files: certificates and keys are often stored as base64 text between header lines.
Base64 is not encryption
Anyone can decode base64 instantly with a base64 encoder decoder; it hides nothing. It is a way to carry bytes safely as text, not a way to protect them. Never treat a base64 string as secret. A password sent with HTTP Basic authentication is only protected if the connection itself uses HTTPS. If you need confidentiality, use real encryption, and if you need to store passwords, use a password hashing function.
Standard and URL-safe base64
RFC 4648 defines two alphabets. The standard one uses + and /, which have special meanings in URLs and file names. The URL-safe alphabet replaces them with – and _, and often drops the = padding. The bytes FB FF encode to +/8= in standard base64 and -_8= in URL-safe base64. The standard alphabet is what this base64 encoder decoder uses; to decode a URL-safe string, change – back to + and _ back to /, and add = until the length is a multiple of four.
Why decoding can fail
- The string contains characters outside the alphabet, such as spaces copied from an email.
- Padding is missing or the length is not a multiple of four.
- The decoded bytes are not valid UTF-8 text, for example when the original was an image or other binary file.
File size and line breaks
Because every 3 bytes become 4 characters, a 30 KB image becomes about 40 KB of base64 text, and a 3 MB email attachment travels as roughly 4 MB. That overhead is why large files are usually sent as links rather than embedded data URLs. Some systems also insert a line break every 76 characters, as MIME email does; a strict base64 encoder decoder may reject those breaks, so remove spaces and line breaks before decoding if you get an error.
The tool encodes text as UTF-8 first, so accented letters, symbols and emoji work. The same text encoded with a different character set, such as Latin-1, would produce different base64. When a decoded result shows strange characters, the original was probably not UTF-8 text, or it was a binary file such as an image, which should be saved as a file rather than read as text. A good habit is to decode a short sample with the base64 encoder decoder before processing a large batch.
Related converters and calculators
Related tools:
- Binary converter: bits
- Data storage converter: bytes
- Random number generator: random values
- Unit converter: units
Sources
IETF RFC 4648: The Base16, Base32, and Base64 Data Encodings; MDN Web Docs: Base64.
Formula and method
Encode: btoa(unescape(encodeURIComponent(text))). Decode: decodeURIComponent(escape(atob(text))).
Text packaging with Base64. Encoding is not encryption. Invalid Base64 fails cleanly.
Questions about this calculator
What is base64 used for?
Carrying binary data as plain text, for example in email attachments and data URLs.
Is base64 encryption?
No. Anyone can decode it.
Why does base64 end with =?
= is padding added when the last group has fewer than 3 bytes.
How much bigger is base64?
About 33%: every 3 bytes become 4 characters.
What is URL-safe base64?
A variant that uses - and _ instead of + and /.
Check the assumptions and units before relying on a result. Financial, tax and health estimates do not replace advice for your individual circumstances.
Report a calculation issue