Logo

Base64 to Image

Paste a Base64 string or Data URL and get your image back — free, instant, browser-based

Paste Base64 or Data URL

Paste the String, Get the Picture Back

You have a wall of random-looking text and you need the image it came from. Maybe an API returned it, maybe it was buried in a database row. Staring at it tells you nothing, and half the tools you find want you to sign up first. This Base64 to image decoder just does the job.

Paste the string, click Decode, and your picture appears. Nothing uploads anywhere. If you need the opposite direction, our image to Base64 converter handles the encoding side.

We built this after getting tired of decoders that fail silently. When something is wrong with your string, this one tells you what and why.

How to Use This Base64 Image Decoder

Four steps, and only the first one needs any thought.

  1. Paste your string. A bare Base64 blob works. So does a full Data URL beginning with data:image.
  2. Glance at the character count. It warns you if the length is not a multiple of four.
  3. Click Decode to Image. The preview appears with the format and pixel size.
  4. Hit Save. You get a real file with the right extension.

One thing we tell our clients: that character count is worth reading. In our experience, most "broken" strings are simply truncated. Someone copied from a terminal that clipped the output, and the last few thousand characters never made it.

What Base64 to Image Conversion Actually Does

Base64 is not encryption and it is not compression. It is a way to write binary data using only plain text characters. Every three bytes of your image become four letters, digits, or symbols.

That matters because plenty of systems refuse to carry raw binary. JSON APIs, email bodies, and older config formats all expect text. Encoding an image as Base64 lets it travel through them untouched.

Decoding reverses the arithmetic exactly. You get back the same bytes you started with — same pixels, same quality, same file size. Nothing degrades.

The honest downside sits on the encoding side, not here. Base64 inflates a file by roughly 33%, which is why we wrote a whole piece on when to use Base64 images and when to leave them as ordinary files.

Data URI to Image: Reading the Header

A Data URI carries its own label. The part before the comma tells the browser what it is holding:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...

Three pieces matter there. data: marks the scheme. image/png is the MIME type. ;base64 says the payload is encoded rather than percent-escaped.

When that header is present, we trust it and skip detection entirely. When it is missing, we read the first few characters of the payload instead. A PNG always starts iVBORw0KGgo. A JPEG starts /9j/. A GIF starts R0lGOD.

Here is the caveat nobody mentions: a wrong header beats no header. If a server labels a JPEG asimage/png, browsers usually still render it, so the bug hides for months. Our green confirmation bar names the format it used, which is often the first time people spot the mismatch.

Picking the Right Output Format

Decoding gives you back whatever format was encoded. Converting to something else is a separate decision, and it is not free.

When to save Base64 to PNG

Choose PNG for logos, icons, screenshots, and anything with transparency. PNG is lossless, so the pixels survive intact. It also keeps the alpha channel, which is the whole reason your logo does not sit on an ugly white square.

Our dedicated convert Base64 to PNG page handles this, including strings that were originally JPEGs.

When converting Base64 to JPG makes more sense

Photographs are the case for JPEG. A photo saved as PNG can be five to twenty times larger than the same photo as JPEG, because PNG was never designed for continuous-tone images.

Be careful, though. JPEG is lossy, so every re-save throws away a little more detail. Converting a PNG screenshot to JPEG will smear the text edges — we see this constantly in support tickets. The Base64 to JPG converter is the right tool for photos and the wrong one for UI mockups.

If you need a format this page does not cover, our online image converter handles WebP, AVIF, HEIC, and ICO.

Why Your String Refuses to Decode

Five causes explain nearly every failure we see. In rough order of frequency:

  • Truncation. The copy was cut short. Base64 length is always divisible by four.
  • A pasted header the decoder did not expect. Server libraries choke on the data: prefix.
  • base64url characters. Dashes and underscores replacing plus and slash.
  • Hex, not Base64. If it is only digits and the letters a–f, it is hexadecimal.
  • Double encoding. Someone encoded an already-encoded string. Decode it twice.

We flag the first one automatically. The rest show up as an error that names the likely cause rather than a generic "invalid input" message. That is deliberate: a decoder that only says "failed" wastes your afternoon.

Is It Safe to Decode Private Images Here?

Yes, because your string never leaves the page. Everything runs in JavaScript inside your browser. There is no upload, no server-side processing, and no temporary storage bucket.

You can prove it yourself. Open your browser dev tools, switch to the Network tab, and decode something. You will see no outbound request.

One genuine caution, though, and it applies to every decoder: be careful with SVG from sources you do not trust. SVG is XML and it can carry embedded JavaScript. We show previews inside an<img> tag, which browsers refuse to run scripts from, but never host an untrusted SVG on your own domain.

Where Encoded Images Turn Up in Real Work

Most people land here because something else handed them a string they did not ask for. The usual suspects:

  • API responses. Avatar and thumbnail endpoints often return Data URLs instead of file links.
  • Database columns. Small images stored as text rather than in blob storage.
  • Email templates. Inline images that survive clients blocking remote content.
  • CSS files. Tiny icons inlined to save a network request — see our guide to Base64 images in CSS and HTML.
  • Log files and JWTs. Debug dumps that embedded a screenshot.

Working the other direction is just as common. If you are building any of the above, you will want to encode a PNG to Base64 first, or use our Base64 encoder and decoder for plain text and non-image files.

Frequently Asked Questions

Why does my decoded image have a black background where it used to be transparent?

+
You saved it as JPG. The JPEG format has no alpha channel, so transparent pixels have to become something solid. We paint white behind the image before converting, but other tools default to black. If transparency matters, save as PNG instead.

My string starts with data:application/octet-stream — will it still decode?

+
Not as-is, and that header is a common server bug rather than a broken image. Some backends label every binary download that way. Delete the whole header up to and including the comma, then paste just the Base64 part and let our detector work out the real format.

Can I decode a Base64 string pulled straight out of a database BLOB column?

+
Usually yes, but check what the driver returned first. Some clients hand you a hex string like 89504e47 rather than Base64, and hex will never decode here. If your string is only digits and the letters a to f, it is hex and needs converting first.

Why does the same string work in my browser but fail in my backend code?

+
Nine times out of ten the backend is being handed the full Data URL. Server libraries expect only the payload after the comma, not the data:image/png;base64, prefix. Strip the header before you pass the string to your decoder.

My string uses - and _ instead of + and /. What is that?

+
That is base64url, a URL-safe variant defined in RFC 4648. It swaps the two characters that break inside URLs and often drops the = padding too. Replace the dashes with plus signs and the underscores with slashes, then it will decode normally.

The string came from an email and has a line break every 76 characters. Is it corrupt?

+
No, it is doing exactly what the MIME spec asks for. RFC 2045 wraps Base64 at 76 characters so old mail servers do not choke. We strip whitespace automatically before decoding, so you can paste it as-is.

Can I recover the original filename from the Base64 string?

+
No, and no other tool can either. Base64 encodes the file contents and nothing else — the name lives in the filesystem or the HTTP header, not inside the data. We name the download image plus the detected extension.

Does decoding strip EXIF data like camera settings or GPS coordinates?

+
Plain decoding keeps everything, because the bytes are rebuilt exactly as they were. Converting between formats is different: re-encoding through a canvas drops EXIF entirely. That is a privacy win if you are sharing photos, and a real loss if you needed the metadata.

My decoded SVG shows up enormous or microscopic. Why?

+
SVG files without a width and height attribute scale to whatever container holds them. In our preview that means it stretches to the panel. The file itself is fine — add width, height, or a viewBox when you use it in your page.

Is it safe to decode a Base64 string that somebody else sent me?

+
Treat SVG with real caution. An SVG can contain JavaScript, so an attacker can hide a script inside one and hope you open it directly. We render the preview inside an img tag, which blocks scripts, but never serve an untrusted SVG from your own domain.

The Short Version

Paste, decode, download. That is the whole workflow for turning Base64 to image files, and it takes about four seconds.

What sets this decoder apart is what happens when things go wrong. Format detection without a header, a truncation warning before you waste time, and errors that name the actual cause. Those are the parts we would want if we were on your side of the screen.

Related Tools You Might Like

Advertisement