Developer & Data

Base64 to image: decode data URLs, fix broken <img> tags, and download PNG/JPG

Turn a Base64 string into an image file. Learn raw Base64 vs data URLs, common decoding errors, and safe browser-based conversion.

Feb 24, 20263 min readBy Mateo Díaz
base64debuggingdevelopers
TLDR
  • Base64 image strings need the right MIME type and a clean data URL prefix to preview correctly.
  • If an image will not render, check padding, whitespace, and whether the bytes actually describe an image.
  • Convert Base64 images back to files for debugging, documentation, or handing assets to another tool.

Use it now

Base64 to Image Converter

Open tool
Glass code card with encoded glyphs converting into a clear image thumbnail card

If you have a Base64 string and you need an actual image file, you do not need a custom script.

Start here:

  • Open Base64 to Image.
  • Paste your Base64 string or full data URL.
  • Preview and download the image.

Textavia decodes Base64 locally in your browser.

Quick start: the two formats you will see

1) Full data URL (best)

It starts like this:

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

A data URL includes the MIME type. The converter can auto-detect the format.

2) Raw Base64 only

It starts like this:

iVBORw0KGgo...

If you only have raw Base64, pick an image type in the tool (or leave auto-detect on and sanity-check the preview).

What Base64 is (and why images use it)

Base64 is a text encoding for binary data.

Images are binary files. When you need to embed an image inside HTML, CSS, JSON, or an API payload, Base64 is a common workaround.

Examples

Example 1 (beginner): convert a data URL to a PNG file

  1. Copy the full string starting with data:image/....
  2. Paste it into Base64 to Image.
  3. Download.

Example 2 (professional): debug a broken <img src>

If an <img> tag shows a broken image icon:

  • confirm the string starts with data:image/ if it is meant to be a data URL
  • confirm there is a comma after base64

Correct:

data:image/webp;base64,AAAA...

Common bug:

data:image/webp;base64AAAA...

Example 3 (professional): fix URL-encoded Base64

Sometimes Base64 is sent through a query parameter and gets URL-encoded.

Signs:

  • lots of %2F, %2B, or %3D

Fix:

  1. URL-decode it with the URL encoder/decoder.
  2. Then decode the Base64 to an image.

Common Base64-to-image errors

What you seeWhat it usually meansFix
Preview is blankwrong MIME type or corrupted Base64try a different type, or recopy the string
Error about invalid Base64whitespace or non-Base64 charsremove spaces/newlines; recopy clean
Output downloads but won't openyou decoded Base64URL or non-image dataconfirm it is image data; try the Base64 tool

If you only do 3 things

  • Paste the full data:image/...;base64,... string when you have it.
  • If you only have raw Base64, verify the image type by previewing.
  • If you see %2F and %3D, URL-decode first.

Sources and further reading

  • RFC 4648: The Base16, Base32, and Base64 Data Encodings
  • RFC 2397: The "data" URL scheme

Privacy and security

Textavia's Base64 decoding runs locally in your browser. Your data is not uploaded to a server.

Written by

Mateo Díaz

Builds, tests, and documents Textavia's tools, drawing on degrees in computer science and mathematics and a habit of explaining things plainly.

View author profile

Related tools

Related guides