Base64 turns any data into a string of plain letters, digits and a couple of symbols, so it can travel safely through systems built for text, such as email, URLs, JSON and HTML. Developers meet it in API tokens, data URLs and email attachments. Our Base64 encoder and decoder converts text to Base64 and back, handling accented letters and emoji correctly with UTF-8. This guide explains how Base64 works.
How to use the tool
- Mode: encode or decode.
- Text: the text to encode, or the Base64 string to decode.
With the defaults, encoding Hello, world! gives SGVsbG8sIHdvcmxkIQ==. Decoding SGVsbG8= gives Hello.
How Base64 works
Base64 takes the input as bytes and processes it in groups of three bytes (24 bits). Each group is split into four 6-bit chunks, and each chunk maps to one of 64 characters:
- A to Z (values 0 to 25)
- a to z (26 to 51)
- 0 to 9 (52 to 61)
- + and / (62 and 63)
Example: "Hel"
- Bytes: H = 72, e = 101, l = 108.
- In binary: 01001000 01100101 01101100.
- Regrouped into 6 bits: 010010 000110 010101 101100.
- Values: 18, 6, 21, 44.
- Characters: S, G, V, s.
So "Hel" becomes SGVs. The binary calculator and binary and hex converter help you follow the bits.
Padding with =
When the input length is not a multiple of three bytes, the last group is padded:
- One leftover byte produces two characters plus ==.
- Two leftover bytes produce three characters plus =.
"Hello" is 5 bytes, so it encodes to 8 characters ending in one =: SGVsbG8=.
Size overhead
Every 3 bytes become 4 characters, so Base64 is about 33% larger than the original. A 300 KB image becomes about 400 KB when embedded as Base64. That is the trade-off for being text-safe.
Where Base64 is used
- Email attachments: MIME encodes binary files as Base64 so they pass through text-only mail systems.
- Data URLs: small images embedded directly in HTML or CSS, such as
data:image/png;base64,.... - APIs and authentication: HTTP Basic authentication sends
username:passwordas Base64. JSON Web Tokens use a URL-safe Base64 variant. - Storing binary data in JSON, XML or databases that expect text.
- Configuration and keys: certificates and keys in PEM format are Base64 between header lines.
Base64 is not encryption
Anyone can decode Base64 instantly; it provides no security. Never use it to hide passwords or sensitive data. HTTP Basic authentication is only safe over HTTPS for exactly this reason. For strong passwords, use the password generator.
URL-safe Base64
Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe variant replaces them with - and _ and often drops the = padding. If you need to put text in a URL without Base64, use percent-encoding with the URL encoder and decoder.
UTF-8 and special characters
Base64 works on bytes, not characters. Text is first turned into bytes with UTF-8, where letters like é take two bytes and emoji take four. This tool handles that automatically, so "café" encodes correctly and decodes back to exactly the same text.
Troubleshooting decoding
- Invalid characters: Base64 only contains A–Z, a–z, 0–9, +, / and =. Remove spaces, line breaks or quotes copied by mistake.
- Wrong length: valid Base64 (with padding) has a length that is a multiple of 4.
- Garbled output: the data may be binary (an image or file) rather than text, or URL-safe Base64 that needs - and _ converted back.
Base64 in everyday development
Most programming languages include Base64 in their standard library, such as btoa and atob in browsers, the base64 module in Python and Convert.ToBase64String in .NET. Be careful with browser btoa, which only accepts Latin-1 text and fails on emoji unless you convert to UTF-8 bytes first. When debugging an API, decoding a token or header with this tool is often the quickest way to see what is inside. Remember that JSON Web Tokens have three Base64 sections separated by dots, and only the first two are readable data; the third is a signature.
Frequently asked questions
Is Base64 secure?
No. It is an encoding, not encryption. Anyone can decode it, so never rely on it to protect sensitive data.
Why does Base64 end with = signs?
The = characters are padding, added when the input length is not a multiple of three bytes.
Why is Base64 bigger than the original?
Every 3 bytes of input become 4 characters, which adds about 33% to the size.
Can I encode emoji and accented letters?
Yes. The tool uses UTF-8, so any Unicode text encodes and decodes correctly.
Try it yourself
Run your own numbers with our free tool: Base64 encode / decode. No sign-up, and it works on any device.