Base64 Encoder / Decoder

Encode or decode Base64 strings with full UTF-8 support. 100% client-side.

Input
Output
Paste text above to encode or decode Base64.

How to Use the Base64 Encoder/Decoder

  1. Paste your text or Base64 string into the input area on the left (or top on mobile).
  2. Choose a mode — Encode, Decode, URL-Safe Encode, or URL-Safe Decode.
  3. View the result — the converted output appears instantly on the right.
  4. 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.

Frequently Asked Questions

Base64 is a binary-to-text encoding scheme that represents binary data as an ASCII string. It uses 64 printable characters (A-Z, a-z, 0-9, +, /) to represent data. Base64 is commonly used to embed binary data in text-based formats like JSON, XML, HTML, and email.
URL-safe Base64 replaces the + character with - and / with _, and removes trailing = padding. This variant is safe to use in URLs and filenames without percent-encoding. It is commonly used in JWTs, data URIs, and URL query parameters.
Yes. This tool uses the TextEncoder and TextDecoder APIs to correctly handle multi-byte UTF-8 characters, including emojis, CJK characters, and accented letters. Standard btoa/atob only handles Latin-1, but our implementation works with the full Unicode range.
No. All encoding and decoding happens entirely in your browser using JavaScript. Your data never leaves your machine. There is no server-side processing, no logging, and no data collection.
Since everything runs in your browser, the limit depends on your device's available memory. In practice, this tool handles inputs up to several megabytes on modern devices. For very large files, consider using a command-line tool like base64 on Linux or certutil on Windows.