Developer tools
Base64 decoder and encoder
This Base64 decoder turns Base64 text back into the original bytes or UTF-8 text, and the same page encodes text or any file to Base64. Conversion runs in your browser: choose Encode or Decode, pick an alphabet, then convert, copy or download the result.
Input
Choose what to do and provide your input.
Choose any file. All its bytes, including metadata, will be encoded.
Output
Your result will appear here.
Binary result. These bytes are not displayable UTF-8 text. Download the file to preserve them exactly, and choose the extension that matches the original format.
Decoded downloads preserve the original bytes. Base64 is an encoding, not encryption.
Choose your options, add text or a file, then convert.
How to encode or decode Base64
To decode Base64, choose Decode as the Operation, paste the Base64 text or choose a file, then select Convert. To encode, choose Encode and provide the text or file you want turned into Base64.
- Set Operation to Encode or Decode, and set Input source to Text or File.
- Choose the Alphabet: Standard (+ /) for most uses, or URL-safe (- _) for URLs and filenames. When encoding, toggle Include = padding; the option is unavailable while decoding, since padding is read from the input instead.
- Type or paste text, or use Choose file. To encode, choose any file: all its bytes, including metadata, are encoded. To decode, choose a UTF-8 text file that holds Base64 or a base64 data URL.
- Select Convert. Copy output copies a text result. Download output saves any result; after a conversion you can change the name in Download filename. Reset clears the input and the result and restores the default options.
Choosing an alphabet and padding
Decoding accepts only the characters of the selected alphabet, so a - or _ under Standard, or a + or / under URL-safe, reports an error naming the alphabet the character belongs to. Each alphabet has 64 symbols, so every character carries 6 bits; 4 characters together carry 24 bits, exactly 3 bytes, which is why Base64 text is grouped in fours. Padding adds trailing = characters so the encoded length is always a multiple of 4, and encoding can include or omit it; decoding accepts either padded or unpadded input, provided the padding present sits correctly, since a = in the wrong position is rejected.
RFC 4648 lets a decoder reject a last character whose unused bits are not zero, and this decoder does. That catches some cut or changed strings whose length looks valid. It cannot catch every change: a changed character in the middle of otherwise valid Base64 still decodes, to different bytes. Neither the padding choice nor this check changes the bytes a valid conversion produces.
What happens to invalid Base64
Decoding validates every character before producing output. A character outside the selected alphabet, misplaced padding, a single leftover character after the last full group of four, or nonzero unused bits in the final character all stop the conversion with a message naming the exact character and its position, and, for pasted text, that character is selected in the input box.
ASCII spaces, tabs and line breaks inside Base64 text are ignored, matching how Base64 is often copied from other sources with line wrapping. A leading UTF-8 byte-order mark before the Base64 text is also ignored, rather than treated as part of the payload. When decoding, a data: URL is accepted directly: the tool reads the literal Base64 payload after the comma and ignores the declared MIME type, without fetching or rendering anything. Only a literal data:...;base64, prefix is recognized; a percent-escaped or non-Base64 data URL is not supported, so paste just the Base64 content in that case.
Limits
This tool sets no size limit. Your browser's memory and its maximum text length are the limits, and a file too large to read as text stops with an error. Output longer than 1,000,000 characters is shown as a preview of its first part in the Output box, while Copy and Download always use the complete result regardless of length. Encoding a very large file meets a related limit: the whole file loads into memory and the encoded output joins into one string, so an oversized file can also stop with an error, though the browser sets the ceiling and no fixed figure applies.
Encoding text with an unpaired UTF-16 surrogate character is rejected, since that half-character cannot become valid UTF-8 bytes on its own. Decoded binary output that is not valid UTF-8, or that contains binary control characters, downloads correctly but shows no text preview; download the file and open it with software that understands its format.
Questions
What is URL-safe Base64, and when do I need it?
URL-safe Base64 swaps the standard alphabet's + and / for - and _, so the result needs no escaping inside a URL, filename or cookie value. Choose it when the encoded text is going into one of those places. Decoding rejects characters from the other alphabet and names which one the character belongs to.
How can I decode a Base64 image?
Choose Decode, paste the Base64 text or its data:image/...;base64, URL, and select Convert. The page shows no image preview. Change the name in Download filename to the right extension, such as .png, then select Download output. The file holds the exact original bytes.
Why did decoding fail with a padding or character error?
The decoder checks every character against the selected alphabet, any = padding position, a single leftover character and the unused bits of the last character. The message names the exact character and position, and, for pasted text, that character is selected. Base64 has no checksum, so a changed middle character still decodes, to different bytes.
Does Base64 encoding make my data bigger?
Yes. Base64 groups bytes in 3s and encodes each group as 4 characters, so encoded output runs about 33% larger than the original bytes, before any padding. Base64 is reversible, not a form of compression, so it never reduces size.
Is it safe to decode Base64 online?
On this page, your data stays in your browser tab. Encoding and decoding run in a Web Worker, Convert loads only this tool's own code from the site, and the text or file you convert is not sent anywhere. Base64 is not encryption, so anyone who has the encoded text can decode it.
How do I Base64 encode a file?
Choose Encode as the Operation and File as the Input source, then select Choose file and pick any file; all its bytes, including metadata, are encoded as they are. Select Convert, then Copy output for text or Download output to save the file. This tool sets no size limit; your browser's memory and text length are the practical limits.
Is Base64 the same as encryption?
No. Base64 only re-encodes bytes as text; it uses no key and adds no secrecy, so anyone with the encoded text can decode it immediately. Use encryption, not Base64, to keep data secret. This tool performs the encoding and decoding only.
Related tools
- Compare two JSON documents: decode a Base64-encoded JSON payload here, then diff it against another version.
- Encode an image as Base64: get a data URI, an HTML image tag or a CSS background for an image file.
- Percent-encode or decode a URL: escape a string for a URL before or after Base64-encoding it.