User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Drop a .txt file here or click to paste from clipboard
0 characters Supports raw Base64, Data URIs, and URL-safe Base64
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

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.

base64 file converter base64 decode data uri binary converter base64 to image base64 to pdf

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:

Sencoded = 4 โ‹… Soriginal3

Where the division rounds up to the next integer (ceiling). The inverse operation recovers the original byte count:

Soriginal = 34 โ‹… Sencoded โˆ’ P

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 FormatMagic Bytes (Hex)MIME TypeTypical ExtensionBase64 Prefix Chars
PNG89 50 4E 47image/png.pngiVBOR
JPEGFF D8 FFimage/jpeg.jpg/9j/
GIF47 49 46 38image/gif.gifR0lG
WebP52 49 46 46 .. .. .. .. 57 45 42 50image/webp.webpUklG
BMP42 4Dimage/bmp.bmpQk
TIFF (LE)49 49 2A 00image/tiff.tiffSUkq
TIFF (BE)4D 4D 00 2Aimage/tiff.tiffTU0A
ICO00 00 01 00image/x-icon.icoAAAB
SVG3C 73 76 67 or 3C 3F 78 6Dimage/svg+xml.svgPHN2
PDF25 50 44 46application/pdf.pdfJVBE
ZIP50 4B 03 04application/zip.zipUEsD
GZIP1F 8Bapplication/gzip.gzH4sI
RAR52 61 72 21application/x-rar.rarUmFy
7Z37 7A BC AFapplication/x-7z.7zN3q8
MP3 (ID3)49 44 33audio/mpeg.mp3SUQz
WAV52 49 46 46 .. .. .. .. 57 41 56 45audio/wav.wavUklG
OGG4F 67 67 53audio/ogg.oggT2dn
FLAC66 4C 61 43audio/flac.flacZkxh
MP4.. .. .. .. 66 74 79 70video/mp4.mp4AAAA (varies)
WebM1A 45 DF A3video/webm.webmGkXf
WOFF277 4F 46 32font/woff2.woff2d09G
WOFF77 4F 46 46font/woff.woffd09G
WASM00 61 73 6Dapplication/wasm.wasmAGFz
EXE/DLL4D 5Aapplication/x-msdownload.exeTVo
SQLite53 51 4C 69application/x-sqlite3.dbU1FM
JSON (heuristic)7B or 5Bapplication/json.jsoneyJ / W
XML3C 3F 78 6Dapplication/xml.xmlPD94
Plain TextUTF-8 heuristictext/plain.txtVaries

Frequently Asked Questions

The browser's native atob() function will throw an InvalidCharacterError for strings with illegal characters or incorrect padding. If the string decodes but was truncated, the resulting file will be shorter than expected. For images, this typically manifests as a partially rendered image with a gray or black band at the bottom. For ZIP archives and PDFs, the file will be unreadable. Always verify the decoded file size matches the expected original: Soriginal = 34 โ‹… Sencoded โˆ’ P.
Yes. The converter automatically detects and normalizes URL-safe Base64 variants per RFC 4648 ยง5. Characters - are replaced with + and _ with / before decoding. Missing padding (=) is also restored. This covers tokens from JWTs, URL parameters, and data transmitted through systems that prohibit + and /.
When no data:[mime];base64, prefix is present, the tool decodes the first 16 bytes and compares them against a signature database of known magic bytes. For example, PNG files always begin with 89 50 4E 47 0D 0A 1A 0A. MP4 files contain 66 74 79 70 at byte offset 4. Text-based formats (JSON, XML) are identified via UTF-8 validity heuristics and opening character analysis. If no signature matches, the file defaults to application/octet-stream.
The practical limit depends on browser memory. Strings exceeding approximately 100MB decoded may cause tab crashes. For strings larger than 1MB (approximately 1.33MB encoded), this tool offloads decoding to a Web Worker to keep the UI responsive. Chrome's V8 engine has a string length limit of approximately 512MB (229 characters). Firefox's limit is similar.
Three common causes: (1) The Base64 string contains line breaks or whitespace that inflate the character count but are stripped before decoding. (2) The string includes a Data URI prefix which is metadata, not payload. (3) Padding characters (=) were stripped during transmission. The tool handles all three cases by cleaning the input before processing. The true decoded size is always 34 of the cleaned Base64 character count, minus padding bytes.
Yes. Base64 is format-agnostic. Any binary encoded as Base64 decodes back to its original bytes. The tool recognizes signatures for EXE/DLL (4D 5A), WebAssembly (00 61 73 6D), SQLite (53 51 4C 69), and dozens of others. The decoded file downloads with the correct extension. Verification is your responsibility: always check file integrity with a hash comparison when available.