Btoa-decode Data
Encode and decode Base64 data online using btoa/atob. Supports UTF-8 text, real-time conversion, file download, and copy to clipboard.
About
Base64 encoding maps arbitrary binary data onto a 64-character ASCII subset (A - Z, a - z, 0 - 9, +, /) plus = padding. Every 3 input bytes produce 4 output characters, inflating size by approximately 33%. The browser-native btoa function only handles Latin-1 codepoints (0 - 255). Feeding it raw UTF-8 multibyte characters (emoji, CJK, Cyrillic above U+00FF) throws a DOMException. This tool wraps the call through encodeURIComponent and percent-byte expansion so full Unicode survives the round-trip.
Incorrect Base64 handling silently corrupts payloads in JWT tokens, data URIs, SMTP attachments, and API request bodies. A single missing = pad or an illegal character like # will break a parser downstream. This tool validates the input character set and padding length before decoding, reports the exact error position, and shows byte-level statistics so you can verify data integrity before pasting the result into production code.
Formulas
Base64 encodes every group of 3 input bytes (24 bits) into 4 output characters (6 bits each). The output length formula:
where Lin = input byte length and Lout = output character count including padding.
The size overhead ratio is constant at the limit:
The UTF-8 shim used in this tool performs the following transformation for encoding:
And for decoding:
Padding rules: when Lin mod 3 = 1, two = pads are appended. When Lin mod 3 = 2, one = pad is appended. When divisible by 3, no padding is needed.
Reference Data
| Character Range | Index | Binary Pattern | Count | Notes |
|---|---|---|---|---|
| A - Z | 0 - 25 | 000000 - 011001 | 26 | Uppercase Latin |
| a - z | 26 - 51 | 011010 - 110011 | 26 | Lowercase Latin |
| 0 - 9 | 52 - 61 | 110100 - 111101 | 10 | Decimal digits |
| + | 62 | 111110 | 1 | Standard alphabet |
| / | 63 | 111111 | 1 | Standard alphabet |
| = | - | - | 1 | Padding character |
| - | 62 | 111110 | 1 | URL-safe replaces + |
| _ | 63 | 111111 | 1 | URL-safe replaces / |
| Size Ratios | ||||
| Input bytes | Output chars | Overhead | ||
| 1 | 4 | 300% | ||
| 2 | 4 | 100% | ||
| 3 | 4 | 33.3% | ||
| 57 | 76 | 33.3% (MIME line) | ||
| 768 | 1024 | 33.3% | ||
| Common MIME Contexts | ||||
| Email (SMTP) | RFC 2045 - line length β€ 76 chars, CRLF line endings | |||
| Data URI | data:[mime];base64,... - no line breaks | |||
| JWT | Base64url (no padding, - and _) | |||
| PEM Certificate | 64-char lines between BEGIN/END markers | |||
| HTTP Basic Auth | Authorization: Basic + Base64(user:pass) | |||
| XML (MTOM) | xsd:base64Binary - whitespace permitted | |||
| S/MIME | RFC 8551 - signed or encrypted payloads | |||
| Git objects | Pack files use modified Base64 internally | |||