Base64 Encoder and Decoder
Encode text and files to Base64 or decode them back, with URL-safe output, padding, line lengths, data URLs and clear error messages.
- Free, no sign-up
- Runs in your browser
- Sources cited
- Standard (+ /)
- URL-safe (- _)
- One line
- 76 (MIME, email)
- 64 (PEM, keys)
Ignores spaces and line breaks, and accepts either alphabet and missing padding.
Text is encoded as UTF-8, so any language and emoji work.
Base64
- Input bytes
- 29
- Output characters
- 40
- Size change
- 0.4%
Files
Any file, up to 20 MB, read on your device.
Everything runs in your browser. Nothing you enter is uploaded.
How to use the Base64 encoder and decoder
Choose a direction
Encode text to Base64, decode Base64 to text, or let the tool detect which you pasted.
Type or paste
The result updates as you type. You can also open a text file.
Set the options
Choose the standard or URL-safe alphabet, keep or drop the = padding, and wrap lines at 76 characters for email or 64 for keys.
Work with files
Encode any file to Base64 or a data URL, or download decoded bytes as a file; the tool names it by its detected type.
Copy, download or swap
Copy the result, download it, or send it back to the input to reverse the conversion.
How Base64 works
Base64, defined in RFC 4648, writes binary data using 64 printable characters: A to Z, a to z, 0 to 9, + and /. Every 3 bytes, 24 bits, are split into four groups of 6 bits, and each group picks one character. When the data does not divide into 3 bytes, the last group is padded with =, so encoded text is always a multiple of 4 characters long.
Text has to become bytes first. This tool uses UTF-8, so letters from any language and emoji are encoded correctly and decode back to the same text. Encoded output is about a third larger than the input: 4 characters for every 3 bytes.
RFC 4648 also defines a “URL and filename safe” alphabet that uses - and _ instead of + and /, because those two have special meanings in addresses and file paths; padding is often left off there too. Email bodies in MIME, from RFC 2045, break Base64 into lines of at most 76 characters. A data URL puts a whole file inside a link, as data: followed by its type, ;base64, and the encoded bytes.
Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide passwords or secrets.
Worked example
The text Man is three bytes: 01001101 01100001 01101110. Regrouped into pieces of 6 bits they read 010011 010110 000101 101110, the values 19, 22, 5, 46, which are the characters TWFu.
With one byte fewer, TWE= needs one = to reach a multiple of four characters, and TQ== needs two. Hello, world! is 13 bytes and encodes to SGVsbG8sIHdvcmxkIQ==, 20 characters; decoding gives back “Hello, world!”.
The check mark ✓ is a single character but 3 bytes in UTF-8, so it encodes to 4pyT. The same two bytes that are +/8= with the standard alphabet are -_8 with the URL-safe alphabet and no padding.
Understanding the result, and common mistakes
- Decoded bytes, not text
- When decoded data is not valid UTF-8 text, such as an image, the tool shows the first bytes in hexadecimal and lets you download it as a file.
- Size change
- How much larger or smaller the output is than the input: encoding adds about 33%.
- Mixing alphabets. A token with - or _ is URL-safe Base64; lenient decoding accepts both, strict decoding does not.
- Missing padding. Some systems drop the = signs; lenient decoding adds them back.
- Line breaks in pasted data. Lenient decoding ignores them; strict decoding reports their position.
- Treating Base64 as a secret. It is reversible by anyone.
Frequently asked questions
Is my data uploaded?
No. Encoding and decoding run in your browser.
Why does decoding show hexadecimal?
The bytes are not text, for example an image or a compressed file. Download them as a file instead.
What is URL-safe Base64?
The same encoding with - and _ instead of + and /, often without padding, so it can go in addresses and file names unchanged.
How do I make a data URL for an image?
Encode the file with “As a data URL” on, then use the result as the image address in HTML or CSS.
Is Base64 encryption?
No. It only changes how bytes are written. Anyone can decode it.
Sources
- RFC 4648: The Base16, Base32, and Base64 Data EncodingsRFC Editor · retrieved Nov 14, 2026
- RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part OneRFC Editor · retrieved Nov 14, 2026
- RFC 2397: The “data” URL schemeRFC Editor · retrieved Nov 14, 2026
About these results
- Encoding and decoding run in your browser. Nothing you enter is uploaded.