Skip to content
Initurn

Convert Base64 to an image

Files never leave your device. All processing happens in your browser.

How to convert Base64 to Image

  1. 1

    Paste your Base64 string — with or without the data: prefix.

  2. 2

    Press Convert. The real format is detected from the decoded bytes.

  3. 3

    Preview the image, then download it.

Base64 image data turns up in places it is awkward to get out of: an API response, a database column, a stylesheet, a JSON export, a saved HTML page, a webhook payload. This decodes it back into an actual image file you can open, edit or attach.

What it accepts

  • A full data URI beginning data:image/png;base64, — the prefix is stripped automatically.
  • A bare Base64 payload with no prefix at all.
  • Strings with line breaks, spaces or indentation still in them, as happens when copying out of formatted JSON or a stylesheet.
  • URL-safe Base64 using dashes and underscores instead of plus and slash, which some APIs use so the value survives being put in a URL.

The format is detected, not guessed from the prefix

Every image format begins with a distinctive signature — PNG starts with a specific eight-byte sequence, JPEG with FF D8 FF, GIF with the letters GIF8, WebP with RIFF followed by WEBP a few bytes later. This tool decodes the data first and then reads those bytes to decide what the file actually is, so you get the correct extension even when the data URI prefix is missing, wrong or was invented by whatever produced the string.

When it fails, and what that means

Truncation is by far the most common problem. Base64 strings are long, and copying them out of a terminal, a log viewer or a spreadsheet cell frequently cuts them short or inserts an ellipsis in the middle. A truncated string often still decodes into bytes — it simply produces a broken or half-drawn image. If the result looks cut off halfway down, you are missing the end of the string rather than hitting a bug.

The other frequent cause is copying surrounding syntax with the value: JSON quotes, a trailing comma, CSS url() parentheses, or HTML attribute quotes. Any of those make the string invalid. Select only what sits between the delimiters.

Why the size looks wrong

The decoded file is about a quarter smaller than the text you pasted, which is expected: Base64 stores three bytes of data as four text characters, so removing the encoding removes that overhead. A 400 KB string producing a 300 KB image is the encoding coming off, not data being lost.

Privacy

Decoding happens entirely in this tab. Nothing you paste is transmitted anywhere, which is worth knowing given that Base64 blobs pulled out of API responses and databases are frequently identity documents, signatures, medical scans and other things that should not be pasted into someone else’s server.

Questions about Base64 to Image

Do I need to include the data:image/png;base64, part?

No. It is stripped if present and ignored if absent. The actual format is worked out from the decoded bytes rather than from the prefix, so you get the right file type either way.

My string has line breaks and spaces in it. Will it still work?

Yes. Whitespace and line breaks are removed before decoding, which handles strings copied out of formatted JSON, stylesheets or wrapped log output.

The image comes out half-drawn or cut off. Why?

The string is almost certainly truncated. Base64 image data is long and copying it from a terminal, log viewer or spreadsheet cell often clips the end or inserts an ellipsis. Copy the complete value and try again.

I get "not valid Base64". What is wrong?

Usually surrounding syntax came along with the value — JSON quotes, a trailing comma, CSS url() parentheses or HTML attribute quotes. Select only the string itself, between the delimiters.

Why is the downloaded file smaller than the text I pasted?

Because Base64 stores three bytes as four characters, adding about a third. Removing the encoding removes that overhead, so a file roughly a quarter smaller than the text is exactly right.

Does it handle URL-safe Base64?

Yes. Dashes and underscores are converted back to plus and slash before decoding, so values from APIs that use the URL-safe alphabet work without any editing.

Is what I paste sent anywhere?

No. Decoding runs in JavaScript in this tab on your own device. That matters here, because Base64 blobs from APIs and databases often contain documents, signatures or scans.