How to use Base64 Encoder and Decoder
- Set Conversion to Text or file to Base64, or to Base64 to text or file.
- Pick a Base64 variant: standard, URL-safe or MIME.
- Paste text in Input, or choose one file up to 12 MiB. For an image file, you can turn on the data URI option.
- The converted value updates as you change the input. Copy the text or download the result.
Example: Base64 Encoder and Decoder
Encode a small PNG as an image data URI, then decode that value back to the image.
Options
- Conversion
- Encode turns text or a file into Base64. Decode turns Base64 back into text or a file. The decoder reads either alphabet, so the variant need not match the pasted value.
- Base64 variant
- Standard keeps + and /. URL-safe uses - and _ and drops padding. MIME keeps the standard alphabet and wraps long output for email.
- File (optional)
- One file up to 12 MiB. Encoding gives a .txt download. Decoding a recognized image uses its image extension; unknown binary stays .bin. Leave this empty when you paste text.
- Make an image data URI when encoding an image file
- When you encode a file, this includes its media type before the Base64 text, as in data:image/png;base64,... . Use the plain Base64 option if the receiving app expects only the encoded characters.
Supported inputs and limits
Where your input is processed
This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.
Three variants write three different strings
The same bytes produce different text depending on the variant, and the difference is small enough to cause real bugs. Standard and MIME share the + and / characters. URL-safe swaps in - and _ and removes padding. Only MIME adds line breaks, at 76 characters with CRLF, which is the shape a MIME body part uses for its encoded content.
Questions about Base64 Encoder and Decoder
Why does my encoded text end with one or two = signs?
Each = marks a group of three bytes the input did not fill, so a decoder knows the original length. Hello is five bytes, so the last group holds two and standard Base64 adds one =.
My decode says the bytes are not valid UTF-8. What happened?
The Base64 was valid, but the bytes are not text. A recognized image gets a preview and the matching image extension. Other binary data is kept off the page and offered as a .bin download.
Is Base64 a way to hide a value?
No. There is no key and no password, so anyone can decode the text. Use an encryption tool when the content must stay private, and keep the key in a separate channel.
Which variant should I choose for a URL or an API token?
URL-safe. It replaces + and / with - and _, so the value survives a query string or a file name, and drops the = signs some systems reject.
Can I turn an image into a data URI and get it back?
Yes. For example, choose mark.png, select standard Base64 and turn on Make an image data URI when encoding an image file. The output starts data:image/png;base64, followed by the encoded bytes. Paste that full value into Decode to get a PNG download and preview. The tool checks the declared image type against the bytes and rejects a mismatch.