Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to plain text — with full UTF-8 and file support

0 characters
0 characters
File to Base64 Data URI

Drag and drop a file or click to select — converts to a Base64 data URI you can embed directly in HTML or CSS.

📁 Drop a file here or click to browse

Quick Reference
  • Encode: btoa(unescape(encodeURIComponent(str))) — handles full UTF-8
  • Decode: decodeURIComponent(escape(atob(str))) — reverses the process
  • Data URI: data:image/png;base64,iVBOR... — embed files inline
  • Size increase: Base64 output is ~33% larger than the original binary data

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters. It was designed to carry binary data across channels that only reliably support text content. The 64 characters used are A-Z, a-z, 0-9, +, and /, with = used as padding. When you Base64-encode a piece of data, every 3 bytes of input become 4 characters of output, which is why Base64 encoded strings are always approximately 33% larger than the original data.

Why Does Base64 Exist?

Base64 encoding solves a fundamental problem in computing: safely transmitting binary data through systems designed for text. Email protocols like SMTP were originally designed to handle only 7-bit ASCII text. When you need to attach an image, PDF, or any binary file to an email, MIME (Multipurpose Internet Mail Extensions) uses Base64 to convert the binary attachment into safe ASCII text that can travel through email servers without corruption. The same principle applies to embedding images directly in HTML or CSS using data URIs, storing binary data in JSON (which only supports text), and encoding credentials for HTTP Basic Authentication headers.

How to Use This Base64 Encoder

Using this tool is straightforward. In Encode mode, simply type or paste your text into the input field and the Base64-encoded output appears instantly as you type. In Decode mode, paste a Base64 string to convert it back to the original text. For files, use the drag-and-drop area to convert any file into a Base64 data URI that you can embed directly in your HTML, CSS, or JavaScript code. The tool handles full UTF-8 encoding, meaning it correctly processes special characters, emoji, and text in any language — not just ASCII.

Common Use Cases

  • Data URIs in web development: Embed small images, fonts, or SVGs directly in HTML or CSS to reduce HTTP requests and improve page load performance. Example: <img src="data:image/png;base64,...">
  • API authentication: HTTP Basic Authentication encodes username:password in Base64 for the Authorization header. Note that this is encoding, not encryption — always use HTTPS.
  • Email attachments: MIME encoding uses Base64 to safely transmit binary attachments through text-only email protocols.
  • Storing binary in JSON or XML: Since JSON and XML are text formats, binary data like images or certificates must be Base64-encoded to be stored inline.
  • JWT tokens: JSON Web Tokens use Base64url encoding (a URL-safe variant) for the header and payload sections.

Important: Base64 Is NOT Encryption

A critical misconception is that Base64 provides security. It does not. Base64 is a reversible encoding — anyone can decode it instantly without any key or password. Never use Base64 to "encrypt" passwords, API keys, or sensitive data. If you need to protect data, use proper encryption algorithms like AES-256 or secure hashing functions like SHA-256. Base64 is purely a data representation format, similar to how hexadecimal represents numbers — it transforms data into a different format but provides zero confidentiality.