Encode text and files to Base64 instantly. Create data URIs for images, encode email attachments, and convert any data to Base64 format. Supports URL-safe encoding and file uploads. Perfect for developers working with data URIs, API authentication, and embedded content.
Upload images and generate complete data URIs ready for embedding in HTML or CSS.
Encode any file type: images, PDFs, documents, binary files, and more.
Everything runs locally in your browser. Your files and text never leave your device.
Paste text, upload a file, choose encoding options, and get Base64 output.
Replace + and / with - and _.
Add data:[mime];base64, prefix.
Privacy-first
All encoding happens locally. No uploads.
Understanding how Base64 converts binary data to ASCII text for safe transmission
Base64 encoding is a binary-to-text encoding scheme that converts binary data into a sequence of printable ASCII characters. It's called "Base64" because it uses 64 different characters (A-Z, a-z, 0-9, +, and /) to represent data. Each Base64 character represents exactly 6 bits of data, meaning every 3 bytes of input produces 4 bytes of Base64-encoded output.
When you encode text or files to Base64, the tool converts your data (text, images, documents, or any binary file) into bytes, then transforms those bytes into Base64 characters. This process makes your data safe for transmission over protocols that only support ASCII text, such as email, URLs, HTTP headers, XML documents, and HTML/CSS data URIs.
Hello World!
12 bytes (text)
SGVsbG8gV29ybGQh
16 bytes (+33% size, ASCII-safe)
The encoding process groups input bytes into sets of three (24 bits total), then splits those 24 bits into four groups of 6 bits each. Each 6-bit group is mapped to one of 64 printable ASCII characters. If the input isn't evenly divisible by 3, padding characters (=) are added to the end of the output to indicate the number of bytes in the final group.
For text and file encoding, this means your data can contain any characters, binary content, images, or special symbolsโand they'll all be safely represented as ASCII text. This is why Base64 is the standard encoding for email attachments, data URIs in HTML/CSS, API authentication, and embedding binary data in text-based formats.
Standard Base64 uses the characters + and /, which have special meanings in URLs and must be percent-encoded. URL-safe Base64 replaces these with - and _ respectively, and typically omits the = padding. This makes the encoded string safe to use directly in URLs, query parameters, and filenames without additional escapingโessential for API tokens, OAuth parameters, and RESTful API endpoints.
Base64 is an encoding method, not encryption. Anyone can decode Base64 back to the original data instantly. Never use Base64 alone to protect sensitive information. For security, use proper encryption (AES-256, RSA) before Base64 encoding.
Common use cases where Base64 encoding is essential
Embed images directly in HTML or CSS using data URIs. Encode images to Base64 and embed them inline, eliminating separate HTTP requests and improving page load performance for small images.
SMTP and email protocols require 7-bit ASCII text. Base64 encoding allows binary attachments (images, PDFs, documents) to be transmitted safely through email systems.
HTTP Basic Authentication uses Base64 to encode credentials. API keys, tokens, and authentication strings often use Base64 encoding for safe transmission in headers and URLs.
Pass complex data or binary content through URL query parameters safely. URL-safe Base64 avoids special character encoding issues in web applications and REST APIs.
Store binary data in text-only database columns or XML documents. Base64 ensures data integrity and prevents encoding issues across systems and platforms.
Transmit binary files over text-only protocols (JSON, XML, email). Base64 encoding converts any file type (images, PDFs, documents) into ASCII-safe text for transmission.
Why developers choose Base64 for data transmission
Three simple steps to convert your data to Base64 format
Paste your text into the input field or click "Upload File" to select an image, document, PDF, or any file type. The tool supports both text input and file uploads, making it versatile for encoding any data type. For images, the tool automatically detects the MIME type and can generate complete data URIs ready for HTML or CSS embedding.
Supported file types:
Select URL-safe encoding if you're creating tokens, passing data through URL parameters, or need the output to work in filenames. This replaces + and / characters with - and _, making the string URL-compatible without percent encoding. Enable the data URI prefix if you're embedding data in HTML or CSSโthis adds the full data:[mime];base64, prefix. For text encoding, choose the appropriate MIME type (text/plain, text/html, application/json, etc.).
Click the Encode to Base64 button to convert your text or file. The tool uses standard Base64 encoding with UTF-8 support for international characters in text, ensuring compatibility with all modern systems. For files, binary data is encoded directly. The output shows the size change (typically +33% for Base64 overhead) and the encoded string. Copy the result to your clipboard or download it as a text file for immediate use in data URIs, email attachments, API requests, or embedded content scenarios.
Example Base64 output:
SGVsbG8gV29ybGQh
Or with data URI: data:text/plain;base64,SGVsbG8gV29ybGQh
Expert tips for efficient and secure Base64 usage
When creating API tokens, OAuth parameters, or passing data through URLs, always use URL-safe Base64 encoding. Standard Base64's + and / characters cause issues in URLs and query parameters. URL-safe encoding replaces them with - and _, eliminating the need for percent encoding and preventing transmission errors.
Data URIs are perfect for embedding small images (<10KB) directly in HTML or CSS, eliminating HTTP requests and improving page load speed. For larger images, use regular image files as Base64 increases size by 33%, making large images inefficient. Keep data URIs for icons, logos, and small graphics.
When generating data URIs, use the correct MIME type for your content. For images: image/png, image/jpeg, image/gif, image/svg+xml. For text: text/plain, text/html, application/json. The tool auto-detects MIME types for uploaded files, but you can manually select the type for text encoding.
Critical: Base64 is encoding, not encryption. Anyone can decode Base64 instantly using built-in browser tools or online decoders. Never store passwords, API keys, or sensitive data in Base64 alone. Use proper encryption (AES-256, RSA) before encoding, or use secure tokens with cryptographic signatures.
Base64 increases data size by 33%. For large files (>100KB), this overhead significantly impacts performance and bandwidth. Use compression (gzip, brotli) instead, or serve files directly. Base64 works best for small payloads like small images (<10KB), short text strings, and embedded configuration data.
When encoding text with international characters (emoji, accented characters, Chinese/Japanese text), ensure your tool uses UTF-8 encoding before Base64. JavaScript's native btoa() only handles ASCIIโyou must use encodeURIComponent() first. This tool handles UTF-8 automatically.
Everything you need to know about Base64 encoding
Paste your text into the input field or upload a file, choose encoding options (URL-safe, data URI prefix), and click Encode. The tool will convert your text or file to Base64 format that you can copy or download.
Base64 encoding converts binary data to ASCII text, making it safe for URLs, email attachments, embedding images in HTML/CSS (data URIs), API authentication, and transmitting data over text-only protocols.
Yes. Upload an image file (PNG, JPG, GIF, SVG, etc.) and the tool will encode it to Base64. Enable the data URI prefix option to get a complete data URI ready for use in HTML or CSS.
URL-safe Base64 replaces + with - and / with _ characters, making the encoded string safe to use in URLs and filenames without escaping. Standard Base64 uses characters that need URL encoding.
A data URI embeds Base64-encoded data directly in HTML or CSS. Format: data:[mediatype][;base64],<data>. For example, data:image/png;base64,iVBORw0KG... embeds an image directly in your HTML.
No. All encoding happens locally in your browser using JavaScript. Your text and files never leave your device and are not uploaded to any server.
No. Base64 actually increases data size by approximately 33% because it converts every 3 bytes into 4 ASCII characters. Use gzip or brotli compression for reducing file size, not Base64.
You can encode any file type: images (PNG, JPG, GIF, SVG, WebP), documents (PDF, DOCX), text files, binary files, and more. Base64 encoding works with any binary data.
Use Base64 for embedding images in CSS/HTML (data URIs), email attachments, API authentication headers, transmitting binary data over JSON/XML, storing binary data in text databases, and passing data through URL parameters safely.
This tool can handle large files (several MB), but Base64's 33% size increase makes it impractical for very large files. For data URIs, browsers support up to ~2MB. For email attachments, keep files under 25MB for most email providers.
Yes. This tool uses UTF-8 encoding before Base64 conversion, correctly handling emoji, accented characters, Chinese/Japanese text, and all Unicode symbols in text input.
This tool is perfect for testing, debugging, and one-off encoding. For production apps with high volume, integrate Base64 encoding directly into your codebase using native libraries (Buffer in Node.js, btoa in browsers, base64 module in Python) for better performance.
Explore tutorials on Base64 encoding, data URIs, API authentication, and web development best practices.
Explore learning centerMore tools to work with Base64 and data encoding
Decode Base64 strings back to text or files. Perfect for decoding data URIs, email attachments, and API responses.
Encode JSON data specifically to Base64. Perfect for JWT token payloads and JSON-based API authentication.
Decode Base64-encoded JSON data. Perfect for viewing JWT token payloads and API responses.