Base64 Encoder / Decoder
Encode or decode Base64 strings with full UTF-8 support. 100% client-side.
How to Use the Base64 Encoder/Decoder
- Paste your text or Base64 string into the input area on the left (or top on mobile).
- Choose a mode — Encode, Decode, URL-Safe Encode, or URL-Safe Decode.
- View the result — the converted output appears instantly on the right.
- Copy or download — use the buttons above the output to copy to clipboard or download as a text file.
What Is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a set of 64 printable ASCII characters. The standard Base64 alphabet includes uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), plus (+), and slash (/), with equals (=) used as padding. This encoding is essential when you need to transmit binary data through text-based protocols or embed binary content in text documents.
Common Use Cases
- Data URIs — embed images, fonts, and other assets directly in HTML or CSS using
data:image/png;base64,... - Email attachments — MIME encoding uses Base64 to attach binary files to email messages
- API payloads — transmit binary data (images, PDFs, certificates) inside JSON API requests and responses
- Authentication — HTTP Basic Authentication encodes username:password in Base64
- Cryptographic data — store and transmit encryption keys, certificates, and signatures as text
- Configuration files — embed secrets or binary blobs in YAML, TOML, or environment variables
Standard vs. URL-Safe Base64
Standard Base64 uses the characters + and / which have special meaning in URLs. URL-safe Base64 (also called Base64url, defined in RFC 4648) replaces + with - and / with _, and omits the trailing = padding. This variant is used in JSON Web Tokens (JWTs), URL query parameters, and filenames where special characters would cause problems — pair this with our JWT Decoder to inspect token payloads.
UTF-8 Support
JavaScript's built-in btoa() function only handles Latin-1 characters (code points 0-255). This tool uses the TextEncoder and TextDecoder APIs to properly encode and decode multi-byte UTF-8 characters, including emojis, Chinese/Japanese/Korean characters, Arabic, Cyrillic, and other Unicode scripts. The process converts the string to a UTF-8 byte array first, then Base64-encodes each byte.
How Base64 Works Internally
Base64 encoding processes input data in groups of 3 bytes (24 bits). Each group is split into four 6-bit values, and each 6-bit value is mapped to one of 64 characters in the Base64 alphabet. If the input length is not a multiple of 3, padding characters (=) are added. This means Base64-encoded data is always approximately 33% larger than the original binary data.
Size Overhead
Every 3 bytes of input produce 4 bytes of Base64 output. This 33% size increase is an important consideration when Base64-encoding large files. For example, a 1 MB image becomes approximately 1.33 MB when Base64-encoded. For large assets, it is often more efficient to serve them as separate files rather than embedding them inline as Base64.
Base64 in Data URIs
Data URIs use the format data:[mediatype];base64,[data] to embed files directly in HTML or CSS. For example, a small PNG icon can be embedded as data:image/png;base64,iVBOR..., eliminating an extra HTTP request. This technique is most effective for files under 10 KB — larger files are better served as separate assets since Base64 encoding adds 33% overhead. For related encoding and security tools, check out our Hash Generator and .env Redactor.