Skip to content
gohacks.dev
Web

Base64 to Image or File

Decode Base64 or a data URI back to a file: the type is detected from its first bytes, images are previewed and the file can be saved.

Free · No sign-up · Your inputs stay in your browser

Input

Decode Base64 to a file

Output

image/png, 107 B

Detected typeimage/png
First bytes89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52

Runs in this browser. Nothing you paste is sent to a server.

Magic numbers

Most file formats start with a fixed signature: PNG with the bytes 89 50 4E 47, JPEG with FF D8 FF, PDF with %PDF and ZIP with PK. Checking them is how file on Linux and PHP's finfo identify a file regardless of its name, and it is how an upload handler should check what it was sent.

Where Base64 files come from

APIs return generated PDFs and images as Base64 inside JSON, email attachments are Base64 in the raw message, and canvas exports arrive as data URIs. Decoding one by hand is the quickest way to see whether the data or the code that handles it is broken.

Share

Frequently asked questions

How do I know what type of file the Base64 is?
The tool reads the first bytes after decoding and matches them against known signatures. A data: prefix, if present, is used as given.
Why is my decoded image blank or broken?
The Base64 was probably cut short or wrapped with extra characters. A complete PNG ends with the IEND chunk; a truncated one decodes but does not render.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools