Base64 to File Converter
Convert Base64 encoded strings to downloadable files instantly. Auto-detects MIME type, previews images, and supports all file formats.
About
Base64 encoding inflates binary data by approximately 33%, converting every 3 bytes into 4 ASCII characters drawn from an alphabet of 64 symbols (A - Z, a - z, 0 - 9, +, /). This tool reverses that process. Paste a raw Base64 string or a full Data URI and the decoder reconstructs the original binary, identifies the file type via magic-byte signatures, and delivers a downloadable file. Malformed input or truncated strings produce corrupted output that most applications will silently reject. Verify your source encoding before transmission.
MIME detection works in two passes: first the data: URI prefix is parsed if present; then the first 16 decoded bytes are matched against known file signatures. The tool handles images, documents, audio, video, fonts, and archives. For text-based formats (JSON, XML, CSV, plain text), a UTF-8 heuristic is applied. Note: Base64 strings without a Data URI header default to application/octet-stream when no magic bytes match. This is correct behavior per RFC 2045 ยง6.8.
Formulas
Base64 encoding maps each group of 3 input bytes (24 bits) to 4 output characters from a 64-character alphabet. The encoded size relates to the original by:
Where the division rounds up to the next integer (ceiling). The inverse operation recovers the original byte count:
Where Sencoded = length of the Base64 string (excluding whitespace), Soriginal = decoded byte count, and P = number of padding = characters (0, 1, or 2). The size overhead ratio is constant at 43 ≈ 1.333, meaning a 33.3% increase. Each Base64 character encodes exactly 6 bits: log2(64) = 6. The character set per RFC 4648 is: A - Z (indices 0 - 25), a - z (26 - 51), 0 - 9 (52 - 61), + (62), / (63). URL-safe variant replaces + with - and / with _.
Reference Data
| File Format | Magic Bytes (Hex) | MIME Type | Typical Extension | Base64 Prefix Chars |
|---|---|---|---|---|
| PNG | 89 50 4E 47 | image/png | .png | iVBOR |
| JPEG | FF D8 FF | image/jpeg | .jpg | /9j/ |
| GIF | 47 49 46 38 | image/gif | .gif | R0lG |
| WebP | 52 49 46 46 .. .. .. .. 57 45 42 50 | image/webp | .webp | UklG |
| BMP | 42 4D | image/bmp | .bmp | Qk |
| TIFF (LE) | 49 49 2A 00 | image/tiff | .tiff | SUkq |
| TIFF (BE) | 4D 4D 00 2A | image/tiff | .tiff | TU0A |
| ICO | 00 00 01 00 | image/x-icon | .ico | AAAB |
| SVG | 3C 73 76 67 or 3C 3F 78 6D | image/svg+xml | .svg | PHN2 |
| 25 50 44 46 | application/pdf | JVBE | ||
| ZIP | 50 4B 03 04 | application/zip | .zip | UEsD |
| GZIP | 1F 8B | application/gzip | .gz | H4sI |
| RAR | 52 61 72 21 | application/x-rar | .rar | UmFy |
| 7Z | 37 7A BC AF | application/x-7z | .7z | N3q8 |
| MP3 (ID3) | 49 44 33 | audio/mpeg | .mp3 | SUQz |
| WAV | 52 49 46 46 .. .. .. .. 57 41 56 45 | audio/wav | .wav | UklG |
| OGG | 4F 67 67 53 | audio/ogg | .ogg | T2dn |
| FLAC | 66 4C 61 43 | audio/flac | .flac | Zkxh |
| MP4 | .. .. .. .. 66 74 79 70 | video/mp4 | .mp4 | AAAA (varies) |
| WebM | 1A 45 DF A3 | video/webm | .webm | GkXf |
| WOFF2 | 77 4F 46 32 | font/woff2 | .woff2 | d09G |
| WOFF | 77 4F 46 46 | font/woff | .woff | d09G |
| WASM | 00 61 73 6D | application/wasm | .wasm | AGFz |
| EXE/DLL | 4D 5A | application/x-msdownload | .exe | TVo |
| SQLite | 53 51 4C 69 | application/x-sqlite3 | .db | U1FM |
| JSON (heuristic) | 7B or 5B | application/json | .json | eyJ / W |
| XML | 3C 3F 78 6D | application/xml | .xml | PD94 |
| Plain Text | UTF-8 heuristic | text/plain | .txt | Varies |