Base64 Encoder
Encode text and files to Base64 format instantly
Input
Output
Base64 Encoding Examples
Text is converted to Base64 using the RFC 4648 alphabet. Example:
Simple text encoding
Input:
Base64 output:
Click Sample above to load more example data.
What Is Base64 Encoding?
Base64 is an encoding scheme that converts binary data into ASCII text drawn from a 64-character alphabet: upper- and lowercase letters, the digits, + and /. The RFC 4648 specification defines the standard. It's widely used to embed images in HTML/CSS, store binary data in JSON or XML, send attachments in email, and pass data through systems that only accept text. Base64-encoded data is roughly 33% larger than the original binary.
This tool uses the browser's built-in btoa() function for encoding, so whatever you paste or upload is turned into Base64 on your own machine and never travels to us. You can encode plain text, JSON, XML, or upload any file (images, PDFs, etc.) and get the Base64 string. For decoding Base64 back to its original form, use the Base64 Decoder.
How to Use This Tool
Paste or Upload
Type or paste the text you want encoded on the left, or use Upload to pick a file from disk. Any file type works here: plain text, a PNG, a PDF, a compiled binary. Use Sample to load example text and see the encoded output.
Check the Output
Encoded output lands in the right-hand panel. Typed or pasted text is re-encoded on every change. For file uploads, the file is read and converted. Invalid UTF-8 in text may cause errors; use file upload for binary data.
Copy or Download
Copy sends the encoded string straight to your clipboard; Download saves the same string in a .txt file. For embedding images in HTML, use Image to Base64 to get a Data URI directly.
How Base64 Encoding Works
Base64 takes 3 bytes (24 bits) of binary data and represents them as 4 ASCII characters. Each character encodes 6 bits, so the output is always a multiple of 4 characters. Padding with = is added when the input length isn't divisible by 3. The btoa() function in browsers handles this natively for binary strings. For URL-safe encoding (using - and _ instead of + and /), some tools support Base64url per RFC 4648 Section 5.
When encoding images for web use, the result can be used in a Data URI: data:image/png;base64, followed by the Base64 string. This embeds the image directly in HTML or CSS without a separate file. The Image to Base64 tool produces ready-to-use Data URIs for images.
Where Base64 Encoding Helps
Web developers often need Base64 for inline images. Embedding small icons or logos in CSS or HTML avoids extra HTTP requests. Email clients use MIME Base64 for attachments. APIs that accept JSON sometimes require binary data (e.g., profile pictures) as Base64 strings. JSON doesn't support raw binary; Base64 is the standard workaround. If you need help understanding Base64 encoding in specific contexts, AI search tools like Perplexity or Microsoft Copilot can provide detailed explanations.
Config files, environment variables, and secrets are sometimes stored as Base64 to avoid special character issues. Database fields that only accept text can store binary blobs as Base64. If you need to decode Base64 back to text or files, use the Base64 Decoder. For converting Base64 image strings to viewable images, use Base64 to Image.
Frequently Asked Questions
Is my data private?
Yes. The encoding is plain JavaScript executing in this page, and neither your text nor your files are uploaded. Watch the browser's Network tab while you encode something and you will see no request go out.
What's the size limit?
It depends on your browser's memory. Files up to 10–15 MB generally work in Chrome and Firefox. Very large files may cause the tab to slow down or crash. For huge files, consider a command-line tool like GNU base64.
Can I encode images?
Yes. Upload an image file and it will be encoded. For a ready-to-use Data URI (e.g., data:image/png;base64,...), use the Image to Base64 tool, which outputs the full Data URI for direct embedding in HTML or CSS.
What about Unicode or special characters?
btoa() expects a binary string. For Unicode text, you may need to encode to UTF-8 first. This tool handles UTF-8 text when pasted; for complex cases, the output may vary by browser.
Is Base64 encryption?
No. Base64 is encoding, not encryption. Anyone can decode it with a tool like the Base64 Decoder. Never use Base64 to hide sensitive data. For secrets, use proper encryption (e.g., AES) and key management.
Related Tools
For the formal specification, see RFC 4648. MDN's btoa/atob covers browser encoding and decoding.