Base64 Decoder
Professional Base64 decoder with forensic file analysis. Auto-repairs broken strings, detects 50+ file formats (Magic Numbers), and handles legacy text encodings.
About
This is not just a string translator; it is a forensic data recovery tool. Base64 is the de facto standard for embedding binary assets into text-based transport layers (JSON, XML, Email MIME). However, decoding is rarely straightforward. Developers constantly face "URL-Safe" variants, missing padding characters, or legacy character set mismatches (e.g., UTF-8 vs. Windows-1252).
This application implements an Intelligent Decoding Engine. Unlike standard decoders that rely solely on file extensions, this tool inspects the Magic Bytes (file signature) of the decoded binary stream to positively identify the content type. It allows you to recover corrupted images, inspect PDF headers, or extract executable logic from data dumps. The system automatically sanitizes inputs by stripping data: URI headers and normalizing non-standard alphabets before processing.
Formulas
Base64 efficiency calculations are critical for database architecture when storing binary blobs (BLOBs). The encoded size S is related to the original size N by a factor of roughly 1.33.
During decoding, the integer value of 4 characters (6 bits each) is concatenated into a 24-bit buffer, which is then split into 3 bytes (8 bits each). If the input length L &pmod; 4 ≠ 0, the decoder must interpret the padding character = to align the byte stream correctly.
Reference Data
| Format | Hex Signature (Magic Bytes) | Offset | MIME Type | Category |
|---|---|---|---|---|
| PNG Image | 89 50 4E 47 0D 0A 1A 0A | 0 | image/png | Image |
| JPEG Image | FF D8 FF | 0 | image/jpeg | Image |
| GIF89a | 47 49 46 38 39 61 | 0 | image/gif | Image |
| WebP | 52 49 46 46 ... 57 45 42 50 | 0 | image/webp | Image |
| PDF Document | 25 50 44 46 2D | 0 | application/pdf | Document |
| ZIP Archive | 50 4B 03 04 | 0 | application/zip | Archive |
| RAR Archive v5 | 52 61 72 21 1A 07 01 00 | 0 | application/x-rar-compressed | Archive |
| 7-Zip | 37 7A BC AF 27 1C | 0 | application/x-7z-compressed | Archive |
| GZIP | 1F 8B | 0 | application/gzip | Archive |
| MP3 Audio (ID3) | 49 44 33 | 0 | audio/mpeg | Audio |
| FLAC Audio | 66 4C 61 43 | 0 | audio/flac | Audio |
| MPEG-4 Video | 00 00 00 ... 66 74 79 70 | 4 | video/mp4 | Video |
| WAV Audio | 52 49 46 46 ... 57 41 56 45 | 0 | audio/wav | Audio |
| WOFF Font | 77 4F 46 46 | 0 | font/woff | Font |
| WOFF2 Font | 77 4F 46 32 | 0 | font/woff2 | Font |
| TrueType Font | 00 01 00 00 | 0 | font/ttf | Font |
| XML / SVG | 3C 3F 78 6D 6C | 0 | text/xml | Code |
| Java Class | CA FE BA BE | 0 | application/java-vm | Binary |
| Executable (EXE) | 4D 5A | 0 | application/x-dosexec | Binary |