Skip to main content
BT

Base64 to Image

Paste a Base64 string or data URI and preview the decoded image instantly — auto-trims whitespace, lets you pick the assumed format, download in one click.

Did you like the tool? Thanks!
Share:

More Image Tools Tools

IC

Image Cropper

Crop any image to exactly the area you need, with a live preview — nothing is uploaded, everything happens in your browser.

IR

Image Resizer

Resize any image to an exact width and height in your browser — optional aspect-ratio lock, PNG/JPEG/WebP output, nothing uploaded.

IC

Image Compressor

Shrink an image's file size by re-encoding it at a chosen quality level — live before/after size comparison, JPEG/WebP/PNG output, done locally.

IF

Image Flip & Rotate

Flip an image horizontally or vertically and rotate it by any angle — quick 90/180/270° buttons or a free-angle slider, corners never clipped.

IT

Image to Base64

Convert an image into a Base64-encoded string — full data URI or raw Base64, character count, one-click copy, all done locally.

PI

Placeholder Image Generator

Generate a simple placeholder image for wireframes and mockups — custom size, colors and text, auto-sized to fit, PNG/JPEG/WebP output.

IF

Image Format Converter

Convert an image between PNG, JPEG, WebP and BMP entirely in your browser — no upload, instant preview, adjustable quality.

FG

Favicon Generator

Turn any image into a complete favicon package — six PNG sizes plus a combined multi-resolution .ico file, generated locally in your browser.

AA

ASCII Art Generator

Turn a photo into text-based ASCII art, or type a short message as a large block-letter banner — both rendered entirely in your browser.

QC

QR Code Generator

Generate a real, scannable QR code from text, a URL, Wi-Fi details, an email address or a phone number — encoded entirely in your browser, no external API.

Whitespace and line breaks are trimmed automatically. If your string doesn't start with "data:", it's assumed to be PNG — change the assumed format below if the preview fails or looks wrong.

Decoded preview

How to Use Base64 to Image

Paste a raw Base64 string or a full data:image/...;base64,... URI into the box. A preview renders automatically a moment after you stop typing. If your pasted text doesn't already start with "data:", it's assumed to be PNG by default — use the format select to try JPEG or WebP instead if the preview fails or looks wrong. Once a valid image is showing, click download to save it as a file.

About Base64 to Image

Decoding Base64 back into a usable image is, in principle, the exact reverse of encoding one — but in practice, a pasted Base64 string is one of the most common sources of small, invisible corruption you'll encounter, because of how differently text gets handled once it leaves its original context. Copying a long Base64 string out of an email, a text editor, a terminal, or certain messaging apps very often introduces line breaks at fixed intervals (many tools wrap long lines automatically for display, and that wrapping can get preserved literally when you copy the text), extra leading or trailing spaces, or an accidental partial selection that cuts off the first or last few characters. None of these are visible problems when you're looking at the pasted text — a stray newline in the middle of a Base64 string looks completely unremarkable — but every one of them breaks strict Base64 decoding, because whitespace characters simply aren't part of the Base64 alphabet and a decoder that doesn't specifically account for them will either fail outright or silently produce garbled bytes. The other half of the puzzle is knowing what kind of image the bytes actually represent. A full data URI carries this information explicitly in its own prefix — `data:image/png;base64,`, `data:image/jpeg;base64,`, and so on — so the browser knows exactly how to interpret what follows. But it's extremely common to only have the raw Base64 payload on hand, with no such prefix — copied from a database field, an API response that returns just the encoded bytes, or a config file that stores the MIME type separately from the data. In that case, there is no reliable way to determine the original format purely by inspecting the Base64 text itself (multiple image formats can, in principle, start with visually similar-looking encoded bytes), so a sensible tool has to make an assumption and let you correct it. PNG is the most common default assumption for exactly this kind of ambiguous case, since it's the most frequently used lossless format for arbitrary images, screenshots, and graphics — but if a paste turns out to actually be a JPEG or WebP, decoding it as PNG will fail or produce a broken image, and switching the assumed-format selector to the correct type resolves that immediately without needing to re-paste anything. This is also a genuinely useful way to sanity-check a Base64 string you're debugging — confirming that an API response, a stored database value, or a value pulled out of your own code actually decodes into the image you expect, before you commit to using it somewhere else in a project. Because the whole process runs as JavaScript directly in your browser using nothing more than an `<img>` tag's built-in decoding, there's no meaningful limit on what you can safely paste and preview — nothing is transmitted anywhere, and a failed decode simply produces a clear error rather than any risk to your data.

Details & Tips

Processing pipeline, step by step: as you type or paste, input is debounced by 300 milliseconds (a preview re-renders 300ms after your last keystroke, rather than on every individual character) so pasting a very long string doesn't trigger dozens of redundant decode attempts in quick succession. When the debounce timer fires, the current textarea content is stripped of all whitespace — spaces, tabs, and newlines alike — using a single regular-expression replace (`input.replace(/\s+/g, '')`), which fixes the exact copy-paste artefacts described above: wrapped lines, stray leading/trailing spaces, and any accidental extra whitespace picked up in transit. After trimming, the tool checks whether the resulting string already begins with `data:` — if it does, it's used exactly as-is, on the assumption that whatever prefix is present is the correct, intended one. If it doesn't start with `data:`, the tool builds a data URI itself by prepending `data:image/<assumedFormat>;base64,` in front of the trimmed text, where `<assumedFormat>` comes from the format select — defaulting to `png` — that you can change to `jpeg` or `webp` at any time, which immediately re-triggers the same decode logic with the new prefix. The actual decoding is delegated entirely to the browser: the constructed (or as-is) data URI is set directly as an `<img>` element's `src` attribute, and the browser's own native image decoder does the work — this tool contains no custom Base64-to-pixel decoding logic of its own, which is both simpler and more reliable than reimplementing image format parsing in JavaScript. Two events on that `<img>` element drive the rest of the interface: `load`, which fires when the browser successfully decodes and renders the image (this both clears any previous error and enables the download button), and `error`, which fires when the browser cannot make sense of the data — either because the Base64 itself is corrupt/incomplete, or because it decoded as bytes that simply aren't a valid image in the format claimed by the prefix. On an `error` event, the tool shows the message "This doesn't look like valid image data" rather than leaving a broken-image icon on the page, and disables the download button until a subsequent edit produces a successfully decoded preview. Downloading uses the simplest possible approach available: since the currently-previewed data URI is already a complete, self-contained representation of the image, the download button simply creates a temporary `<a>` element with its `href` set directly to that data URI and a `download` attribute set to a filename built from the detected image type (extracted from the `data:image/<type>;base64,` prefix, with `jpeg` mapped to the more conventional `.jpg` file extension), then triggers a click on it — no intermediate Blob construction or conversion step is needed, since the browser already understands how to save a `data:` URI directly to disk via the `download` attribute.

Frequently Asked Questions

Why does the preview only update a moment after I stop typing?
Input is debounced by 300 milliseconds so pasting a long string doesn't trigger many redundant decode attempts in a row — the preview renders once 300ms after your last keystroke or paste, rather than on every individual character.
Why does trimming whitespace matter?
Copying a long Base64 string very commonly picks up line breaks or stray spaces from wherever it was copied, and whitespace isn't part of the Base64 alphabet — even one stray newline in the middle of the string will break strict decoding, so all whitespace is stripped automatically before decoding is attempted.
What happens if my pasted text doesn't start with "data:"?
It's treated as a raw Base64 payload with no format information attached, so the tool assumes PNG by default and builds a data:image/png;base64,... URI for you. Change the format select to JPEG or WebP if the preview fails or looks wrong.
The preview shows an error — what does that mean?
"This doesn't look like valid image data" means the browser's own image decoder couldn't make sense of the bytes — either the Base64 itself is corrupt or incomplete, or it was decoded assuming the wrong format. Double-check you copied the complete string, and try a different assumed format if you didn't include a data: prefix.
How is the image actually decoded?
The constructed data URI is set as a normal <img> element's src attribute, and the browser's own native image decoder renders it — this tool has no custom decoding logic of its own, which is simpler and more reliable than reimplementing image format parsing in JavaScript.
How does the download button work?
It sets a temporary link's href directly to the already-decoded data URI with a download attribute, and clicks it — no separate Blob conversion step is needed, since a data: URI can be saved to disk directly this way.
Is my pasted Base64 string sent to a server?
No. Trimming, format detection, and decoding all happen locally using JavaScript and the browser's built-in image rendering — nothing you paste is transmitted anywhere, which also makes this a safe way to sanity-check sensitive or unpublished image data.
Can I paste a full data URI I copied from somewhere else?
Yes — if it already starts with data:, it's used exactly as-is (after whitespace trimming), and the format select has no effect since the prefix already specifies the correct format.
Why is the download button disabled sometimes?
It stays disabled until the current input successfully decodes into a real image (the <img> element's load event has fired). This prevents trying to download a broken or not-yet-valid result.
What image formats can I decode?
Any format the browser's own image decoder supports — PNG, JPEG and WebP are offered directly in the assumed-format select, and any of these (or other browser-supported formats) will decode correctly if a matching data: prefix is already present in your pasted text.

Part of These Collections

Also Available As

base64 to image, decode base64 image, base64 image viewer, data uri to image, convert base64 string to picture

Found a Problem?

Let us know if something with Base64 to Image isn't working as expected.

Thanks — we'll take a look.