FlipMyFormat

Base64 to Image – Decode and Save Pictures

Paste a data URI, raw Base64 or a whole HTML, CSS or JSON file. See every picture inside with its format and size, then save it as it is or as PNG, JPG or WebP. Free, and nothing is uploaded.

Base64, a data URI, or code that contains images

Need the other direction? Turn a picture into Base64 with Image to Base64.

Decoded in your browser. Nothing you paste is uploaded.

People also use

How to decode Base64 in three steps

Paste a Base64 string in the box above and the picture appears at once. This page turns Base64 to image in your browser: it reads the text, finds the bytes, works out what kind of picture they are and shows a preview with the format, the width and height in pixels and the file size. Press Download to save it, or pick another format first.

You do not need to clean the text up. A full data URI such as data:image/png;base64,iVBOR… works, and so does the bare Base64 after the comma. Line breaks, spaces, missing = padding and the URL-safe letters - and _ are all accepted. You can even paste a whole web page, stylesheet, JSON response, SVG or Markdown file: every embedded picture inside it is found and listed, up to 200 at a time.

Nothing is sent anywhere. The decoding, the preview and the conversion all happen on your own device, so you can safely paste text from private projects, internal APIs or customer emails.

  1. 1

    Paste the Base64

    Paste a data URI, raw Base64 or a whole HTML, CSS, JSON, SVG or Markdown file into the box, or press Open a file to load a text file. Try a sample shows how it works with a small PNG.

  2. 2

    Check the preview

    Each picture found is shown on a checkerboard background with its format, pixel size and file size. Text that is not valid Base64, or bytes that are not a picture, get a red message that explains why.

  3. 3

    Save the picture

    Choose Save as: Keep the format, PNG, JPG or WebP. Press Download on a picture to save it, or Download all (ZIP) when the text held more than one.

The default, Keep the format, saves the exact bytes that were encoded, so the file is identical to the original. Converting to PNG, JPG or WebP redraws the picture in your browser, which is handy when the original format does not open where you need it.

What you can paste

A full data URI

Text that starts with data:image/…;base64, followed by the encoded bytes, as found in HTML src attributes, CSS url() values and many APIs. The prefix is removed for you.

Raw Base64

Just the encoded characters, without any prefix. The page works out the format from the decoded bytes, so you do not have to say whether it is a PNG or a JPG.

URL-safe Base64

The variant that uses - and _ in place of + and /, common in URLs, JSON Web Tokens and some cloud APIs. It is recognised automatically, mixed with the standard alphabet or not.

Text with line breaks or no padding

Base64 wrapped at 64 or 76 characters per line, copied with spaces, or with the = signs at the end missing still decodes. Quotes or a trailing comma around a copied value are trimmed too.

A whole file of code

Paste or open an HTML, CSS, JSON, SVG, XML, JavaScript, Markdown or plain text file. Every data:image URI anywhere inside it is found, up to 200, and each becomes its own preview.

Open a file

The Open a file button loads a .txt, .html, .htm, .css, .json, .svg, .xml, .md or .js file straight into the box, which is easier than copying a very long string by hand.

What Base64 is, and why pictures are stored as text

Base64 was made for systems that only handle text. Email, JSON, XML, HTML attributes and many databases are built around letters and digits, and raw picture bytes would break them: a byte might look like the end of a line, a quote mark or an invisible control character. Base64 avoids that by using only 64 safe characters, A to Z, a to z, 0 to 9, plus and slash, with the = sign for padding at the end.

To do that, it takes the bytes three at a time, which is 24 bits, and splits them into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, and that number picks one of the 64 characters. Decoding simply runs this backwards. Nothing is compressed or encrypted along the way, so anybody can turn the text back into the original picture, and the result is identical to the file that was encoded.

You meet Base64 pictures in many places: icons inside CSS files, logos inside HTML emails, thumbnails and signatures in API responses, photos stored in database columns, pictures saved by canvas.toDataURL in web apps, and attachments inside the raw source of an email.

Base64 to image converter: how the text becomes a picture

Base64 is a way of writing any file as plain letters, digits and a few symbols, so it can travel inside text: an HTML page, a CSS file, a JSON reply or an email. A base64 to image converter simply reverses that. It turns the text back into the original bytes and gives them to you as a picture you can see, save and open in any program.

Here the reversing is done by a small decoder written for this site rather than the browser's own atob function. That matters for big pictures: it works on bytes directly, has no practical length limit for normal photos and screenshots, skips line breaks and spaces, and accepts both Base64 alphabets. If a character in the middle of the text is not part of Base64 at all, it is ignored rather than stopping the whole job.

Once the bytes are back, the page reads their first few bytes, the so-called magic number, to find out what they really are. The format label you see on each preview comes from the bytes themselves, not from the data URI prefix, so a picture labelled image/png that is really a JPG is still shown and saved correctly as a JPG.

Base64 to image online, without uploading anything

Doing base64 to image online usually means pasting your text into a form that sends it to a server. This page works differently: once it has loaded, the decoding runs as code inside your browser tab. Your Base64 never leaves the device, there is no upload progress bar to wait for, and even a picture of several megabytes appears in a moment.

That also means the tool keeps working on a slow or patchy connection after the page has opened. It runs in any current browser on Windows, macOS, Linux, ChromeOS, Android and iPhone, with no add-on, plug-in or app to install.

Base64 to image decoder rules and error messages

As a base64 to image decoder, the page follows a few simple rules. Every four Base64 characters stand for three bytes. Spaces, tabs and line breaks are skipped. The = signs at the end are only padding, so they may be there or not. The characters - and _ are read as + and /, which is how URL-safe Base64 is written.

There is one thing a decoder cannot fix: text that was cut off. Base64 comes in groups of four characters, and if exactly one character is left over at the end, part of the last byte is missing. In that case you see the message “Not valid Base64: the length is wrong (cut off when copying?)”. Copy the value again, making sure you take everything up to the closing quote or bracket.

If the text decodes but the bytes are not a picture, you get a clear message instead of a broken image. When the bytes are another known file type, the message names it, for example a PDF document, a ZIP archive or a font, so you know to use a different tool. When they are something unknown, the message shows how many bytes were decoded.

Base64 to image free: no account, no watermark

You can turn base64 to image free of charge here, with no account, no email address and no limit on how many strings you decode in a day. There is no watermark on the saved picture and nothing is held back for a paid plan.

It can stay free because your own device does the work. Decoding text and drawing a picture are light jobs for any phone or laptop, so there is no server to pay for and no queue.

Save a Base64 to image file, or many in a ZIP

Saving a base64 to image file takes one click on Download. With Save as set to Keep the format, the file is written byte for byte as it was encoded, and it gets a name such as image-1.png, image-2.jpg or image-3.svg, numbered in the order the pictures appear in your text. The file extension always matches the real format found in the bytes.

When the text held more than one picture, a Download all button appears with the number of pictures on it. It packs every readable picture into one ZIP file called base64-images.zip, using the Save as choice for each. Pictures that could not be read are left out of the ZIP, and the count above the previews tells you how many were skipped.

Want a different format? The Save as setting has four choices. Keep the format saves the original bytes. PNG, JPG and WebP redraw the picture in your browser and save it in that format at full size; JPG and WebP use a quality of 92, which keeps the picture sharp while making it much smaller than PNG for photos.

Base64 to PNG: lossless, with transparency

To go from base64 to png, choose PNG under Save as and press Download. If the decoded picture is already a PNG, the original bytes are saved untouched. If it is a JPG, GIF, WebP, BMP or ICO, the picture is drawn at its own pixel size and saved as a PNG, with transparent areas kept transparent.

PNG is the safe choice for logos, icons, screenshots, charts and anything with sharp edges or text, because it is lossless: every pixel is stored exactly. An animated GIF or WebP is saved as one still frame.

Base64 to JPG: smaller files for photos

To go from base64 to jpg, choose JPG under Save as. JPG has no transparency, so transparent areas become white before the picture is saved; that is better than the black background some converters give. If the bytes are already a JPG, they are saved as they are, with no second round of compression.

JPG is a good fit for photos you want to email, upload to a form or place in a document, because the file is much smaller than a PNG of the same photo. If the result is still too large for a form, run it through Compress Image, and if you have a PNG file on disk rather than Base64, PNG to JPG does the same conversion for whole folders of pictures.

Saving as WebP, and which format to pick

WebP is the third conversion choice. It keeps transparency like PNG and makes photos small like JPG, which suits pictures for websites and apps. Every current browser can show WebP, but some older desktop programs cannot open it, so pick PNG or JPG if the file is going into an older editor or office program.

A quick guide to the four Save as choices: keep the format whenever the original opens where you need it, because it is exact and loses nothing. Pick PNG for screenshots, logos, icons and anything with text or transparency. Pick JPG for photos going into email, office documents or upload forms that ask for JPG. Pick WebP for pictures that go back onto a website. The choice applies to every picture you download afterwards, including the ones in the ZIP, so you can switch it before pressing Download all.

On Windows, Mac, iPhone and Android

On Windows and macOS, open the page in Chrome, Edge, Firefox or Safari, paste with Ctrl+V or Cmd+V and press Download. The file lands in your Downloads folder. For a very long value, saving it in a text file and using Open a file is often easier than selecting it all on screen.

On iPhone and iPad, long-press the box and choose Paste, then tap Download on the picture; Safari asks where to save it, or puts it in the Downloads folder of the Files app. On Android, paste the same way and the picture goes to Downloads, where your gallery app can find it. A ZIP of many pictures opens in the Files app on both systems.

On Linux and ChromeOS, any current Chromium or Firefox browser works the same way as on a desktop. No part of the tool needs an install, a plug-in or a sign-in on any device.

A Base64 image viewer with format, size and dimensions

This page also works as a base64 image viewer when you only want to look. Each picture is shown on a light checkerboard, so you can see at a glance which parts are transparent. Under it you see the format in capitals, the size in pixels, for example 24×24 for the sample, and the decoded file size in B, KB or MB.

That makes it quick to check what an API actually returned, which icon a stylesheet embeds, or whether a thumbnail in a database is the size it should be. Large pictures are scaled down to fit the preview box, but the pixel size shown and the file you save are always the full original size.

The preview updates as you type or paste, so you can paste one value after another without pressing any button. Clear empties the box and removes the previews.

Why the text is bigger than the picture

Because four characters carry three bytes, Base64 text is about a third longer than the file it holds. A 30 KB picture becomes roughly 40 KB of text, and line breaks add a little more. That is why the file size shown under each preview is smaller than the length of the text you pasted: it is the size of the real, decoded file you will save.

This is also why large photos are rarely embedded as data URIs on websites. For small icons the saved request is worth it; for photos, a normal file is lighter. If you are cleaning up a page, decoding its data URIs here and saving them as files is a good first step, and Compress Image can shrink them further.

Data URI to image: every picture in HTML, CSS and JSON

A data URI is a link that carries the file inside it: data:, then the type such as image/png, then ;base64, and then the encoded bytes. Web developers use them to put small icons straight into HTML and CSS so the browser does not need an extra request. Going from data uri to image is what the box does automatically, and it works on more than one at a time.

Paste the source of an email template, a saved web page, a CSS file, a JSON export, an SVG with embedded bitmaps or a Markdown note, and the page searches the whole text for every data:image URI with Base64 content. Each one is decoded and shown in the order it appears, up to 200 pictures. This is handy for pulling the logos out of an HTML email, recovering icons from an old stylesheet, or checking which pictures make a page heavy.

Only data URIs that use Base64 are picked up. SVG data URIs that are written as plain or percent-encoded text, without ;base64, are not decoded. If no data URI is found at all, the page treats the whole text as one Base64 value.

The four parts of a data URI

data:

The scheme that tells the browser the content follows in the link itself, instead of at a web address.

image/png

The media type the author claimed. It is often right, but this page checks the bytes and trusts them instead.

;base64

Says the content is Base64. Without it, the content is plain or percent-encoded text, which is common for SVG.

, and the data

Everything after the first comma is the encoded file. This is the part a decoder reads; raw Base64 is just this part on its own.

Convert Base64 to image in JavaScript, Python, PHP and C#

If you need to convert base64 to image inside your own program, the steps are the same in every language: remove the data: prefix if there is one, decode the Base64 to bytes, and write the bytes to a file or show them. Below are short, working examples you can copy. Each assumes the text is in a variable called data.

JavaScript in the browser

atob turns Base64 into a binary string, and Uint8Array turns that into real bytes. For a full data URI, fetch is the shortest route.

// Raw Base64 or data URI to a Blob you can show or save
const b64 = data.replace(/^data:[^,]*,/, '').replace(/-/g, '+').replace(/_/g, '/');
const bin = atob(b64.replace(/\s/g, ''));
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
const blob = new Blob([bytes], { type: 'image/png' });
document.querySelector('img').src = URL.createObjectURL(blob);

// Shorter, when data is a full data URI
const blob2 = await (await fetch(data)).blob();

JavaScript in Node.js

Buffer understands both Base64 alphabets and ignores missing padding.

const fs = require('fs');
const b64 = data.replace(/^data:[^,]*,/, '');
fs.writeFileSync('image.png', Buffer.from(b64, 'base64'));

Python

base64.b64decode needs correct padding, so the example adds it back. Use base64.urlsafe_b64decode for text with - and _.

import base64

b64 = ''.join(data.split(',', 1)[-1].split())   # drop a data: prefix and line breaks
b64 += '=' * (-len(b64) % 4)                    # put back missing padding
with open('image.png', 'wb') as f:
    f.write(base64.b64decode(b64))

PHP

base64_decode skips line breaks in its default mode. Swap - and _ first with strtr if the text is URL-safe.

$b64 = preg_replace('/^data:[^,]*,/', '', $data);
$b64 = strtr($b64, '-_', '+/');
file_put_contents('image.png', base64_decode($b64));

C#

Convert.FromBase64String ignores white space but needs the standard alphabet and correct padding.

var b64 = data.Substring(data.IndexOf(',') + 1)
    .Replace('-', '+').Replace('_', '/');
b64 = b64.PadRight(b64.Length + (4 - b64.Length % 4) % 4, '=');
byte[] bytes = Convert.FromBase64String(b64);
File.WriteAllBytes("image.png", bytes);

These examples save the file as image.png for simplicity. If you do not know the real format, look at the first bytes, as this page does: 89 50 4E 47 is PNG, FF D8 FF is JPG, GIF8 is GIF and RIFF…WEBP is WebP. Or paste the value in the box above once and read the label.

Picture formats recognised from the bytes

PNG

Recognised by its 8-byte signature. Lossless, with transparency. Shown and saved, or converted to JPG or WebP.

JPG / JPEG

The usual photo format. Saved as .jpg. Keep the format avoids a second round of compression.

GIF

Shown with its animation in the preview. Keep the format saves the whole animation; PNG, JPG and WebP save one frame.

WebP

Recognised from its RIFF…WEBP header. Can be saved as it is or turned into PNG or JPG for older programs.

AVIF

Recognised from its ftyp header. Most current browsers show it; if yours does not, the preview stays empty, but Keep the format still saves the file.

HEIC

The iPhone photo format is recognised and saved as .heic. Most browsers cannot draw it, so the preview may be empty and converting may fail; save it with Keep the format, then use HEIC to JPG.

BMP

Old Windows bitmaps are recognised and shown. Converting to PNG makes them far smaller with no loss.

ICO

Favicon files are recognised and saved as .ico, or converted to PNG to get a normal picture of the icon.

SVG

Recognised when the decoded text starts with an svg tag. Saved as .svg with Keep the format. Some browsers cannot redraw SVG for conversion; if you see an error, save the .svg and use SVG to PNG.

When people decode Base64 pictures

Checking an API response

Many APIs return thumbnails, QR codes, signatures or charts as Base64 inside JSON. Paste the whole response and every picture in it is shown, so you can see what came back without writing any code.

Pulling pictures out of HTML email

Email templates often embed logos and banners as data URIs. Paste the HTML source and download all the pictures in one ZIP.

Recovering icons from CSS

Older stylesheets hide icons and backgrounds in url(data:…). Paste the CSS to see each one and save it as a real file you can reuse or edit.

Reading database exports

Pictures stored as Base64 text in a database column or a CSV export can be pasted one at a time and saved with the right file extension.

Debugging a canvas or upload

When canvas.toDataURL or a file reader gives you a long string, paste it here to make sure the picture is what you expected, at the size you expected.

Learning and teaching

Try a sample shows a complete data URI next to its picture, which helps when explaining how Base64 and data URIs work.

Tips for clean results

Copy the whole value

Long strings are easy to cut short. In a code editor, click inside the quotes and use select-to-matching-quote or a double-click on the value, or open the whole file with Open a file instead of copying.

Do not trust the prefix

A data URI saying image/png may hold a JPG. The label on each preview comes from the bytes, so use it, and the saved file name, as the real answer.

Keep the format when you can

Saving the original bytes is lossless and keeps details such as animation, colour profiles and metadata. Convert only when the format does not open where you need it.

Mind metadata

Kept files can still contain camera details or other metadata that was in the original picture. If you plan to share it, Remove Metadata on this site can strip it.

Check the pixel size

If a thumbnail looks blurry in your app, the preview tells you whether the encoded picture is really small or whether it is being stretched by your page.

Paste whole responses

There is no need to dig a value out of a large JSON reply first. Paste everything; the page finds each data URI and ignores the rest.

Common problems and fixes

“Not valid Base64: the length is wrong”

The text was cut off, usually because only part of a long line was selected or a message trimmed it. Copy the full value again, up to the closing quote, bracket or parenthesis.

“These bytes are not an image”

The text decoded, but the bytes do not start like any picture format. Check that you copied the image field and not, for example, an ID or a hash, which also look like Base64.

“This is a PDF document, not an image”

The Base64 holds another kind of file. The message names it. For a PDF, a ZIP or an Office file, decode it with the Base64 tool, which saves any file type.

The preview is empty

The format is known but your browser cannot draw it, which mostly happens with HEIC and sometimes AVIF. Save it with Keep the format, which always works.

“This image could not be converted”

PNG, JPG and WebP output need the browser to draw the picture first. If it cannot, choose Keep the format and convert the saved file afterwards with Convert Image.

The picture has a white background

You saved as JPG, which has no transparency, so transparent areas become white. Choose PNG or WebP, or Keep the format, to keep the transparency.

Only one picture is found in a long file

Only Base64 data URIs are picked up. Pictures linked by normal URLs, or SVGs written as plain text in the data URI, are not part of the text and cannot be decoded here.

The text has quotes around it

One quote mark at each end and a trailing comma or semicolon are trimmed when you paste a single value. If the value still fails, check that no other characters such as a closing bracket were copied with it.

Is it safe? Your text stays on your device

Everything happens in your browser. The text you paste, the files you open and the pictures you save stay on your device and are never uploaded, logged or stored by us. You can check this yourself: once the page has loaded, turn off your network and the tool keeps working.

Because the page only reads text and shows pictures, it cannot run anything that is hidden in the Base64. SVG pictures are shown through an image element, which does not run scripts inside the SVG.

How it works

The page searches your text for data:image URIs with a regular expression and collects their Base64 parts, removing spaces and line breaks. If it finds none, it treats the whole text, minus any quotes at the ends, as one value. Each value is decoded to bytes, and the first bytes are compared with the known signatures of PNG, JPG, GIF, WebP, AVIF, HEIC, BMP, ICO and SVG.

Readable pictures are shown from a temporary blob address inside your browser, and their pixel size is read once they load. For PNG, JPG or WebP output, the picture is drawn on a canvas at its full size, with a white background first for JPG, and saved from there. The ZIP is built in your browser as well.

The temporary addresses are released as soon as you change the text or clear the box, so pasting one large value after another does not keep filling your memory. Closing the tab removes the decoded pictures from memory altogether.

What to do with your pictures next

Need to go the other way? Image to Base64 turns any picture into a data URI or raw Base64, ready for HTML, CSS or JSON. For text or other file types, the Base64 tool encodes and decodes anything, with a choice of character sets and URL-safe output.

Once your picture is saved, Resize Image changes its pixel size, Compress Image makes the file smaller, Convert Image changes the format of many files at once, and PNG to JPG is there when a form only accepts JPG.

Frequently asked questions

How do I use this base64 to image converter?

Paste your Base64 or data URI into the box at the top of the page. The picture appears straight away with its format, pixel size and file size. Press Download to save it, or choose PNG, JPG or WebP under Save as first.

Is base64 to image online safe for private data?

Yes, on this page. The decoding runs in your browser, so the text you paste and the pictures you save never leave your device. Nothing is uploaded or stored on a server.

What does a base64 to image decoder actually do?

It turns each group of four Base64 characters back into three bytes, then hands those bytes over as a file. This decoder also skips line breaks, accepts missing padding and URL-safe characters, and checks the bytes to name the real picture format.

Is it really base64 to image free, with no limits?

Yes. There is no account, no watermark and no daily limit. Your own device does the decoding, so it costs us nothing extra when you use it.

What name does the base64 to image file get?

Pictures are named image-1, image-2 and so on, in the order they appear in your text, with the extension of the real format, such as .png or .jpg. When you save several at once, they come in one ZIP called base64-images.zip.

How do I convert base64 to png?

Choose PNG under Save as, then press Download. A PNG is saved as it is; any other format the browser can draw is redrawn and saved as a lossless PNG, with transparency kept.

How do I convert base64 to jpg?

Choose JPG under Save as and press Download. Transparent areas become white, because JPG cannot store transparency. If the Base64 is already a JPG, the original bytes are saved without a second round of compression.

Can I use this as a base64 image viewer without saving anything?

Yes. Paste the text and look at the preview; nothing is saved until you press Download. Each preview shows the format, the pixel size and the file size, on a checkerboard that makes transparent areas visible.

How does data uri to image work for a whole HTML or CSS file?

Paste or open the whole file. The page searches it for every data:image URI with Base64 content, up to 200, and shows each picture separately. Use Download all to get them in one ZIP.

How do I convert base64 to image in JavaScript or Python?

In the browser, decode with atob, copy the characters into a Uint8Array and wrap it in a Blob, or simply call fetch on a full data URI and read the blob. In Python, use base64.b64decode on the part after the comma and write the bytes to a file opened in binary mode.

Do I need to include the data:image prefix?

No. You can paste a full data URI or only the Base64 after the comma. The format is worked out from the decoded bytes, so the prefix is not needed and a wrong prefix does not matter.

Why do I get “the length is wrong”?

Base64 comes in groups of four characters. If exactly one is left over, the text was cut off, usually while copying. Copy the whole value again, up to its closing quote or bracket.

Why does it say the bytes are not an image?

The text decoded fine, but the result does not start like PNG, JPG, GIF, WebP, AVIF, HEIC, BMP, ICO or SVG. It may be another file type, which the message names when it can, or a value that is not a picture at all, such as a token or hash.

Does it accept URL-safe Base64?

Yes. Text that uses - and _ instead of + and / is recognised automatically. Missing = padding at the end is fine too.

Can it handle Base64 with line breaks?

Yes. Base64 wrapped at 64 or 76 characters per line, as in emails and PEM-style files, decodes normally, because spaces, tabs and line breaks are skipped.

Which image formats are recognised?

PNG, JPG, GIF, WebP, AVIF, HEIC, BMP, ICO and SVG are recognised from their bytes. Your browser must be able to draw a format to preview or convert it; HEIC usually cannot be shown, but it can still be saved as it is.

Can I decode many pictures at once?

Yes. Paste text that contains several data URIs, such as an HTML page or a JSON array, and up to 200 pictures are listed. Download all saves the readable ones in one ZIP.

What happens to transparency when I convert?

PNG and WebP keep transparent areas. JPG cannot store transparency, so those areas are filled with white. Keep the format leaves the original file exactly as it was.

Is there a size limit?

There is no fixed limit; it depends on your device's memory. Normal photos, screenshots and icons decode in a moment, and the decoder has no problem with strings of several megabytes.

Does it work on iPhone and Android?

Yes. Open the page in any current browser, paste the text and tap Download. On a phone, the saved picture goes to your Downloads or Files app, from where you can move it into your photos.

How do I turn a picture back into Base64?

Use the Image to Base64 tool on this site. It turns a picture into a data URI or raw Base64 that you can paste into HTML, CSS or JSON.

Decode your Base64 now

Paste a data URI, raw Base64 or a whole file of code. Preview every picture and save it. Free and private.

Paste your Base64

Last updated October 2026 · Written and maintained by the FlipMyFormat team