Base64 to UTF-8 Converter
Convert Base64 encoded strings to UTF-8 text and vice versa. Supports multi-byte characters, emoji, URL-safe Base64, and file input/output.
About
Base64 is a binary-to-text encoding scheme defined in RFC 4648. It maps every 3 input bytes to 4 ASCII characters from a 64-character alphabet (A - Z, a - z, 0 - 9, +, /), with = padding. A naive atob call in JavaScript returns a Latin-1 binary string, not UTF-8. Any input containing multi-byte sequences (accented characters, CJK ideographs, emoji) will decode to garbage unless each byte is routed through a TextDecoder configured for UTF-8. This tool performs that correct pipeline: Base64 β binary octets β UTF-8 code points. Getting this wrong silently corrupts data in API payloads, JWT claims, email attachments, and data URIs.
The converter also supports URL-safe Base64 (RFC 4648 Β§5), which replaces + with - and / with _, and strips trailing = padding. This variant is mandatory in JWTs and many cloud storage APIs. Limitation: this tool operates entirely in-browser and is bounded by available heap memory. Inputs above approximately 5βMB may cause slowdowns on low-end devices.
Formulas
Base64 encoding maps each group of 3 input octets (24 bits) into 4 output characters (6 bits each). The encoded length is computed as:
where n = number of input bytes. The size overhead is always exactly 13 (33.3%). Padding characters = are appended so Lencoded mod 4 = 0.
The decoding pipeline implemented in this tool:
For URL-safe variant, the pre-processing step replaces characters before decoding:
where Lencoded is the final output length in characters, n is the raw byte count of the input, and ceil is the ceiling function.
Reference Data
| Property | Standard Base64 | URL-Safe Base64 |
|---|---|---|
| RFC | RFC 4648 Β§4 | RFC 4648 Β§5 |
| Alphabet | A - Z, a - z, 0 - 9, +, / | A - Z, a - z, 0 - 9, -, _ |
| Padding | = (mandatory) | Optional / stripped |
| Size Overhead | 33.3% | 33.3% |
| Encoding Ratio | 3 bytes β 4 chars | 3 bytes β 4 chars |
| Use Case | Email (MIME), PEM certs, XML | JWT, URLs, filenames |
| Line Breaks | MIME: every 76 chars | None |
| Input: "A" | QQ== | |
| Input: "AB" | QUI= | QUI |
| Input: "ABC" | QUJD | QUJD |
| Input: "Hello" | SGVsbG8= | SGVsbG8 |
| Input: "β¬" | 4oKs | 4oKs |
| Input: "ζ₯ζ¬" | 5pel5pys | 5pel5pys |
| Input: "π" | 8J+YgA== | 8J-YgA |
| Empty String | (empty) | (empty) |
| UTF-8 BOM | 77u/ | 77u_ |
| Max Line (MIME) | 76 chars + CRLF | N/A |
| Padding Chars Needed | 0, 1, or 2 | None |
| Invalid Characters | Any outside alphabet + = | Any outside alphabet |
| Bit Mapping | 6 bits per character | 6 bits per character |