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 using 64 printable characters (A–Z, a–z, 0–9, +, /). 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. Your input is processed entirely in your browser—nothing is sent to a server. 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
Paste your text into the left editor or click Upload to load a file. The tool accepts any file type—text, images, PDFs, or binaries. Use Sample to load example text and see the encoded output.
Check the Output
The right panel shows the Base64-encoded result. For text input, encoding happens automatically. 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
Use Copy to put the Base64 string on your clipboard, or Download to save it as 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 like MIME use 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.
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. Encoding runs entirely in your browser using JavaScript. No data is sent to any server. You can confirm this by opening your browser's Network tab while using the tool.
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 (e.g., TextEncoder or encodeURIComponent). 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 documentation covers browser encoding. atob() is used for decoding in JavaScript.