Drag & drop a file here or click to browse
File will be encoded as a Base64 data URI
What Is Base64 Encoding and How Does It Work?
Base64 is a binary-to-text encoding scheme that converts arbitrary binary data into a string composed of 64 printable ASCII characters: the uppercase letters A–Z, the lowercase letters a–z, the digits 0–9, and the two symbols + and /. A padding character = is appended when the input length is not a multiple of three bytes. The name "Base64" simply refers to the fact that the encoding uses a 64-character alphabet to represent data. It was originally defined in RFC 4648, which also specifies a URL-safe variant that replaces + and / with - and _ to avoid conflicts in URLs and filenames.
How the Encoding Process Works
The algorithm takes the input data three bytes (24 bits) at a time and splits each group into four 6-bit segments. Each 6-bit value maps to one character in the Base64 alphabet. For example, the ASCII string "Hi" consists of two bytes: H (72, binary 01001000) and i (105, binary 01101001). Together they form 16 bits. Because the input is not a multiple of three bytes, the encoder pads the bit stream to 24 bits, splits it into four 6-bit groups, and uses = for the final character, yielding SGk=. Decoding reverses the process exactly: each Base64 character is mapped back to its 6-bit value, the bits are reassembled into bytes, and padding characters are discarded.
Handling UTF-8 and Multi-Byte Characters
JavaScript's built-in btoa() function only accepts Latin-1 (ISO 8859-1) strings, which means it will throw an error on any character outside the 0–255 range — including emoji, Chinese characters, and accented letters. The standard workaround is to first encode the string to UTF-8 bytes using encodeURIComponent and then map the percent-encoded sequences back to single-byte characters that btoa() can handle. This tool applies that technique automatically, so you can encode any Unicode text — including emoji like 🚀 — without errors.
Common Use Cases for Base64
Base64 appears in a wide variety of contexts across web development, networking, and data processing. Email attachments have historically used Base64 to embed binary files inside MIME messages, since the SMTP protocol was designed for 7-bit ASCII text. Data URIs embed small images, fonts, or other assets directly into HTML and CSS, eliminating extra HTTP requests and simplifying deployment. API payloads in JSON or XML often carry binary blobs — such as profile pictures or signed certificates — as Base64 strings because JSON has no native binary type. JSON Web Tokens (JWTs) use Base64url encoding for the header and payload segments, making them safe to pass in URLs and HTTP headers. Basic HTTP authentication encodes the username:password pair with Base64 before sending it in the Authorization header. And developers frequently use Base64 to quickly inspect or share small binary payloads during debugging without needing specialized hex editors.
Base64 Is Not Encryption
A common misconception is that Base64 provides security. It does not. Base64 is a fully reversible encoding — anyone with access to the encoded string can decode it instantly. It is designed for safe transport, not confidentiality. If you need to protect sensitive data, use proper encryption algorithms such as AES or RSA, and transmit the ciphertext over TLS/HTTPS. Think of Base64 as a packaging format: it changes the shape of the data so it can travel through text-only channels, but it does not lock or hide the contents.
The Size Overhead Trade-Off
Because every three bytes of input produce four bytes of output, Base64 increases data size by approximately 33%. For small assets like icons or configuration snippets, this overhead is negligible. For large files — such as high-resolution images or video — the size penalty becomes significant, and it is usually better to serve those assets as separate binary files with proper caching. The sweet spot for data URIs is typically files under 10 KB, where the saved HTTP request outweighs the encoding overhead.
Frequently Asked Questions
What is Base64 encoding used for?
Base64 is used whenever binary data needs to be represented as text — in email attachments, data URIs, JSON/XML payloads, JWT tokens, HTTP Basic Auth headers, and during debugging. It ensures binary content passes safely through systems that only support ASCII text.
Does Base64 encoding encrypt my data?
No. Base64 is a reversible encoding, not encryption. Anyone can decode a Base64 string. Use AES, RSA, or another encryption algorithm if you need confidentiality.
Why does Base64 output end with = or ==?
The = sign is a padding character. Base64 processes input in groups of three bytes. When the input length is not divisible by three, one or two = characters are added so the output length is always a multiple of four.
Can this tool handle emoji and non-Latin characters?
Yes. The encoder first converts text to UTF-8 byte sequences before applying Base64 encoding, so multi-byte characters like emoji, Chinese, Arabic, and accented letters all work correctly.
This converter runs entirely in your browser — no data is sent to any server. It is free to use with no sign-up required. Paste your text, drag a file, and get results instantly.
Related reading: JWT Tokens Explained: What They Are and How They Work