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 when you change the input or encoding options. Review the text or file type before copying or downloading it.
- Choose a text encoding when working with text. For files, leave pasted text empty; select up to ten files and review each result.
Example: Base64 Encoder and Decoder
Encode 28 bytes of UTF-8 text containing an accented character.
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)
- Choose one file up to 12 MiB. Encoding produces a .txt download. Decoding uses a recognized image type or supported file prefix for the extension; unknown binary stays .bin. Leave the file field empty when using pasted text.
- Make an image data URI when encoding an image file
- Choose a PNG, JPEG or WebP file and standard Base64 to include its image media type before the encoded bytes, such as data:image/png;base64,... . Images must fit the supported 20-megapixel limit. Leave this off when the receiving application expects plain Base64.
- Input
- Paste text to encode or Base64 to decode. Leave this empty if you choose a file. Whitespace in Base64 is ignored.
- Text encoding
- UTF-8, UTF-16LE, UTF-16BE and ISO-8859-1 are explicit choices. Latin-1 rejects characters it cannot represent rather than substituting them. File encoding preserves the original bytes.
- File batch
- Up to ten files, 12 MiB per file and 32 MiB total. Results are processed sequentially, limited to 48 MiB and offered individually and in a ZIP.
- Byte preview
- If the selected encoding cannot decode the bytes, inspect the first 256 bytes as hexadecimal and download the original data.
Supported inputs and limits
- One run takes up to 5,000,000 characters of text or one file up to 12 MiB.
- Standard output keeps its = signs, URL-safe output drops them, and MIME output keeps them and breaks every 76 characters.
- Decoding ignores whitespace and accepts missing padding.
- Recognized image bytes get an image preview and extension; unrecognized binary stays .bin.
- An image data URI whose declared type conflicts with its real signature is rejected.
More details
Base64 is encoding, not encryption, and anyone can reverse it.
A chosen file replaces pasted input.
PDF, GIF, ZIP, SVG and MP3 prefixes receive matching download extensions; these prefix checks do not validate an entire file.
Active preview remains limited to supported images.
A filename inferred from a file header is not a complete file validation.
Base64 is reversible encoding, not encryption.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved 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?
Padding completes the final four-character Base64 group: one = follows two remaining input bytes, and two = signs follow one. Hello is five bytes, so its final two-byte group adds one = in standard Base64.
My decode says the bytes are not valid UTF-8. What happened?
The Base64 decoded to bytes that are not valid UTF-8 text. Supported PNG, JPEG and WebP images can be previewed. Some other file prefixes receive an appropriate download extension; unknown binary stays .bin. A recognized prefix does not prove the complete file is valid or safe to open.
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?
Use the format required by the receiving application or API. URL-safe Base64 replaces + and / with - and _; this tool also omits its trailing padding. Those choices suit many URL and filename contexts, but another system may require standard Base64 or explicit padding.
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.