Base64 Decode and Encode: How Base64 Works and When to Use It
By FindMySum · Last reviewed
To base64 decode a string, paste it into the box above with the direction set to decode: the text appears straight away, and nothing you paste leaves your device. Base64 is a way of writing any bytes, such as an image, a certificate or text in any language, using only 64 plain characters that survive email, URLs, JSON and configuration files without being changed along the way.
When you will meet Base64
Base64 shows up wherever binary data has to travel through a system built for text. Email attachments are Base64 inside the message. Data URLs in web pages (data:image/png;base64,...) embed small images directly in HTML or CSS. JSON Web Tokens are three Base64url sections joined by dots. Kubernetes secrets, many API responses and HTTP Basic authorization headers carry Base64 as well. Decoding one of these is usually the first step in working out what a system is actually sending.
How to use the tool
- Choose the direction: encode turns text into Base64, decode turns Base64 back into text.
- Leave the character set on UTF-8 unless you know the other side uses Latin-1 (older Western European systems) or UTF-16LE (some Windows tools and PowerShell's
-EncodedCommand). - When encoding for a URL, a file name or a token, pick the URL-safe alphabet and consider turning padding off.
- Copy or download the result. The swap button sends the output back into the input with the opposite direction, which is a quick way to check a round trip.
A worked example
The word Man is three bytes in UTF-8: 77, 97 and 110. In binary that is 01001101 01100001 01101110. Split into four groups of six bits you get 010011, 010110, 000101 and 101110, which are 19, 22, 5 and 46. In the Base64 alphabet those values are T, W, F and u, so Man encodes to TWFu. A two-letter word such as Ma leaves only 16 bits, so the encoder adds two zero bits to make three six-bit groups (TWE) and one = to finish the block: TWE=.
Common mistakes
Treating Base64 as security. It hides nothing. If a configuration file stores a password in Base64, the password is effectively in plain view.
Mixing up character sets. The same text gives different Base64 in UTF-8 and UTF-16LE, and decoding with the wrong one produces garbled characters or an error. When the decoded bytes are not valid text at all, the tool shows them as hex instead of inventing characters.
Breaking the string in transit. Copying from a PDF or a chat app can add spaces, line breaks or curly quotes. Spaces and line breaks are ignored when decoding; any other stray character is reported with its position so you can find it.
Forgetting about padding. Some systems insist on the = signs and others reject them. If a decoder elsewhere complains, try the opposite padding setting when you encode.
For numbers rather than text, the number system converter converts between binary, octal, decimal and hexadecimal, and the data storage converter handles bytes, kilobytes and mebibytes.