What is the Base64 Encode / Decode tool?
Base64 is a way to write any data, including files, using only 64 plain text characters; encoding converts to Base64 and decoding converts back. Convert text to Base64 or decode Base64 back to readable text, with full support for emoji and non-English characters. You can also turn a file or image into a Base64 data URL for embedding in HTML, CSS or JSON.
How to use the Base64 Encode / Decode tool
- Choose the Text tab or the File / Image tab.
- In Text mode, type or paste into the Input box, and tick URL-safe if you need URL-safe output.
- Click Encode to turn the input into Base64, or Decode to turn Base64 back into text.
- Read the message under the buttons: it confirms the result or explains why the Base64 is invalid.
- Click Copy above the Output box, or Swap to move the output into Input for another round.
- In File / Image mode, drop a file of up to 10 MB or click to choose one.
- Copy the Base64 string or the ready-made Data URL (for HTML / CSS).
Features
- Encode and decode text with full UTF-8 support
- URL-safe Base64 option (- and _ instead of + and /)
- File and image to Base64 or data URL
- Clear error message for invalid Base64
- Runs locally - nothing is uploaded
What is Base64?
Base64 represents binary data using 64 safe text characters (A-Z, a-z, 0-9, + and /). It is used to embed images in HTML and CSS, send attachments in email, and pass data in URLs and APIs. Every 3 bytes of input become 4 characters, each standing for 6 bits, and one or two = signs pad the end when the input length is not a multiple of 3. Base64 is an encoding, not encryption, so it does not keep data secret.
How text is encoded
Text is first turned into UTF-8 bytes and then into Base64, which is why emoji and non-English letters work: "Hello" becomes SGVsbG8=, while "é" takes two bytes and most emoji take four before encoding. Many simple encoders call the browser's btoa function directly, which fails on any character outside Latin-1; this tool avoids that problem. With URL-safe ticked, the output uses - and _ instead of + and / and drops the trailing = padding.
What the decoder accepts
Decode is forgiving about formatting. It accepts standard and URL-safe Base64, with or without = padding, ignores spaces and line breaks (so wrapped Base64 from an email or PEM-style block pastes fine), and strips a data:...;base64, prefix if you paste a whole data URL. If the input contains characters outside A-Z, a-z, 0-9, +, / and =, or its length shows it has been cut off, you get a clear error instead of garbage. When the decoded bytes are not valid UTF-8 text, the tool still shows them but warns that the result is binary data, so some characters may look strange.
Files, images and data URLs
File / Image mode reads any file type on your device and shows its name, its original size and the size of the Base64 version. Images also get a small preview. You get two outputs: the raw Base64 string, which the URL-safe option can change, and a data URL that always uses standard Base64 and the file's MIME type, such as data:image/png;base64,... A file the browser can't identify is labelled application/octet-stream. Data URLs are handy for small icons in CSS or HTML emails, but large images are better linked as normal files, because Base64 adds about a third to the size and an embedded image can't be cached on its own.
Use cases
Common reasons to encode or decode Base64:
- Embed a small logo or icon directly in a CSS file or HTML email as a data URL.
- Read the payload of a token, configuration value or API response that arrives as Base64.
- Prepare a short text value for a URL parameter or file name with the URL-safe option.
- Check what an encoded string in a log file or database field actually says.
- Convert an image to Base64 for a JSON request to an API that expects inline files.
Limits and privacy
Encoding and decoding run in your browser with JavaScript; your text and files are not uploaded. File mode accepts files up to 10 MB, because Base64 for bigger files is too large to paste anywhere useful. Decode always produces text in the Output box, so the tool can't turn Base64 back into a downloadable file such as an image or PDF; decoded binary data appears as unreadable characters. Remember that anyone can decode Base64, so never treat it as a way to hide passwords or secrets.
| Original size | Base64 length |
|---|---|
| 3 bytes | 4 characters |
| 1 KB (1,024 bytes) | 1,368 characters |
| 1 MB (1,048,576 bytes) | 1,398,104 characters |
Frequently asked questions
Is Base64 encryption?
No. Anyone can decode Base64. Use it for transporting data, never for protecting passwords or secrets.
What is URL-safe Base64?
A variant that replaces + with - and / with _, and usually drops = padding, so the string can be used safely in URLs and file names. The decoder here accepts both forms.
Why is Base64 larger than the original?
Base64 turns every 3 bytes into 4 characters, so encoded data is about 33% larger than the original.
How do I convert an image to Base64?
Switch to File / Image mode and choose your image. You get both the raw Base64 string and a ready-to-use data URL.
Why does it say my Base64 is not valid?
Either the text contains characters that are not part of Base64, or it is the wrong length, which usually means it was cut off when copied. Spaces, line breaks and a data URL prefix are removed automatically.
Can I decode Base64 back into a file?
Not with this tool. Decode shows the result as text, which works for text and JSON but not for images, PDFs or other binary files.