Base64 to HTML Converter
Decode Base64-encoded strings to HTML instantly. Supports standard and URL-safe Base64, live preview, file upload, and download.
About
Base64 encoding represents binary data as ASCII text using a 64-character alphabet (A - Z, a - z, 0 - 9, +, /). It inflates payload size by roughly 33% because every 3 input bytes become 4 output characters. Pasting a corrupted Base64 string into a decoder that silently fails produces garbage HTML that breaks rendering or, worse, injects malformed tags into a production page. This tool validates the input character set and padding before decoding, flags illegal sequences explicitly, and renders a live sandboxed preview so you can verify the markup before committing it to your codebase.
Both standard (RFC 4648 ยง4) and URL-safe (RFC 4648 ยง5) alphabets are accepted. The converter automatically detects URL-safe characters (- and _) and normalizes them. Note: this tool assumes UTF-8 encoded source HTML. Multi-byte sequences outside UTF-8 may produce replacement characters (U+FFFD).
Formulas
Base64 encoding maps every group of 3 input bytes (24 bits) to 4 output characters (6 bits each). The encoded length is calculated as:
where Lin = input byte length, Lout = output character count (including padding). The overhead ratio converges to 43 ≈ 1.333 for large inputs.
Decoding reverses this: each Base64 character is mapped to its 6-bit index value. Four characters produce three bytes:
where idxn is the 6-bit index of the n-th Base64 character. URL-safe decoding first substitutes - โ + and _ โ /, then restores missing = padding to make the length divisible by 4.
Reference Data
| Base64 Character | Index Value | Binary (6-bit) | Notes |
|---|---|---|---|
| A | 0 | 000000 | Uppercase start |
| Z | 25 | 011001 | Uppercase end |
| a | 26 | 011010 | Lowercase start |
| z | 51 | 110011 | Lowercase end |
| 0 | 52 | 110100 | Digit start |
| 9 | 61 | 111101 | Digit end |
| + | 62 | 111110 | Standard alphabet |
| / | 63 | 111111 | Standard alphabet |
| - | 62 | 111110 | URL-safe replaces + |
| _ | 63 | 111111 | URL-safe replaces / |
| = | - | - | Padding character |
| Encoding Overhead Ratios | |||
| Input size | Output size | Ratio | Padding |
| 1 byte | 4 chars | 4:1 | 2 pad chars |
| 2 bytes | 4 chars | 2:1 | 1 pad char |
| 3 bytes | 4 chars | 1.33:1 | 0 pad chars |
| 1 KB | 1.37 KB | 1.37:1 | Typical overhead |
| 1 MB | 1.37 MB | 1.37:1 | Linear scaling |
| Common Base64 Use Cases in HTML | |||
| Data URIs | data:image/png;base64,... for inline images | ||
| Email (MIME) | HTML email body encoding per RFC 2045 | ||
| API payloads | JSON fields containing HTML fragments | ||
| Obfuscation | Template storage in CMS/database blobs | ||
| JWT tokens | URL-safe Base64 in header/payload segments | ||
Frequently Asked Questions
element, which does not execute scripts. The live preview renders inside a sandboxed iframe with the sandbox attribute restricting script execution, form submission, and navigation. Never paste decoded HTML from untrusted sources directly into a production page without server-side sanitization (e.g., DOMPurify or a CSP policy).