A Base64-encoded image is a plain-text representation of the original binary pixels. The encoding uses 64 ASCII characters (A–Z, a–z, 0–9, +, /) plus an optional padding character (=) to map every 6 bits of binary data to one printable character. When you decode the string, you reverse that mapping and reconstruct the exact byte sequence that makes up the JPG, PNG, GIF, or SVG file. Because the process is lossless, the decoded image is pixel-for-pixel identical to the original.
Base64 is widely used whenever binary data must travel through text-only protocols: email attachments, JSON or XML payloads, inline <img> tags in HTML, and even some database fields. Mobile apps often embed small icons or thumbnails as Base64 strings to avoid extra network requests, while web APIs frequently return image previews in the same format. If you receive a long string that starts with data:image/ or simply looks like a random jumble of letters, numbers, and plus signs, it is almost certainly a Base64-encoded image waiting to be decoded.
Decoding the string back into an image is straightforward once you have the right tool. You do not need to install anything, write code, or upload the string to a third-party server. The Base64 Encode / Decode tool on this site runs entirely in your browser, so the entire process stays local. Paste the string, click Decode, and you instantly see the raw bytes or can save them as a file. The tool automatically strips common prefixes like data:image/jpeg;base64, so you can paste the string exactly as you received it.

When you need to decode a Base64 image
- Web development: Extract an inline image from an HTML <img> tag or a JSON response so you can edit it in Photoshop or upload it to a CMS.
- Mobile apps: Convert a Base64 string received from a backend API back into a UIImage or Bitmap so it can be displayed on screen.
- Email attachments: Recover an image that was sent as a long text block in the body of an email instead of as a separate file.
- Database exports: Restore images stored as Base64 strings in CSV or SQL dumps so you can view or archive them as regular files.
- Debugging: Inspect a Base64 string that is not rendering correctly in a browser or app by decoding it and comparing the output to the expected file.
Decode a Base64 image in your browser
- Open the Base64 Encode / Decode tool in any modern browser.
- Make sure the toggle at the top is set to “Decode (Base64 → text)”.
- Paste the entire Base64 string into the input box. The string can include the optional prefix
data:image/xxx;base64,—the tool will ignore it. - Watch the output box update instantly. If the string is valid, you will see a preview of the decoded bytes or a prompt to download the file.
- Click the “Copy” button to copy the raw binary data to your clipboard, or click “Download” to save the image as a file with the correct extension (JPG, PNG, GIF, etc.).
- If the string is malformed, the tool will show a clear error message so you can fix the input and try again.
Common Base64 image prefixes and what they mean
| Prefix | MIME type | File extension | Typical use case |
|---|---|---|---|
data:image/jpeg;base64, |
image/jpeg | .jpg or .jpeg | Photographs, high-quality images with lossy compression. |
data:image/png;base64, |
image/png | .png | Screenshots, logos, images with transparency or sharp edges. |
data:image/gif;base64, |
image/gif | .gif | Simple animations, low-color images, or small decorative icons. |
data:image/svg+xml;base64, |
image/svg+xml | .svg | Scalable vector graphics, icons, or diagrams that should remain crisp at any size. |
data:image/webp;base64, |
image/webp | .webp | Modern web images with smaller file sizes than JPG or PNG. |
These prefixes are defined in RFC 2397 and are widely supported by browsers, email clients, and APIs. When you paste a string that begins with one of them, the Base64 Encode / Decode tool automatically strips the prefix before decoding the actual Base64 payload. This means you can paste the string exactly as you received it without having to edit it first.
How the tool handles edge cases
- Padding characters: Base64 strings are often padded with one or two equals signs (=) to make the total length a multiple of four. The tool accepts both padded and unpadded strings.
- Whitespace: Line breaks, spaces, or tabs anywhere in the string are ignored, so you can paste strings copied from formatted JSON or XML without cleaning them up.
- Unicode and emoji: Although Base64 itself only encodes binary data, the tool supports the full UTF-8 character set in the surrounding text. This is useful if you are decoding a JSON payload that contains both Base64-encoded images and descriptive text with accents or emoji.
- Large files: The tool can decode strings up to 10 MB in size without any noticeable delay. For larger images, the browser may take a second or two to process the data, but the entire operation still happens locally on your device.
- Corrupted input: If the string contains characters outside the Base64 alphabet or has an incorrect length, the tool shows a clear error message instead of silently producing garbage output.
Alternative methods for decoding Base64 images
While the browser-based tool is the fastest way to decode a single image, other methods are available if you need to automate the process or handle many files at once.
- Command line (Linux/macOS):
echo -n "BASE64_STRING" | base64 --decode > image.jpgReplace
BASE64_STRINGwith the actual string (without the prefix) andimage.jpgwith the desired filename. If the string includes the prefix, you can strip it with:echo -n "data:image/jpeg;base64,BASE64_STRING" | sed 's/^data:image\/[^;]*;base64,//' | base64 --decode > image.jpg - Python:
import base64 base64_string = "BASE64_STRING_WITH_OR_WITHOUT_PREFIX" if "," in base64_string: base64_string = base64_string.split(",")[1] image_data = base64.b64decode(base64_string) with open("image.jpg", "wb") as f: f.write(image_data)This script works with or without the prefix and saves the decoded data as a file. You can find more details in our guide Decode Base64 from the Command Line Without Installing Anything.
- JavaScript (browser console):
const base64String = "BASE64_STRING_WITH_OR_WITHOUT_PREFIX"; const byteString = atob(base64String.includes(",") ? base64String.split(",")[1] : base64String); const mimeString = base64String.split(",")[0].split(":")[1].split(";")[0]; const ab = new ArrayBuffer(byteString.length); const ia = new Uint8Array(ab); for (let i = 0; i < byteString.length; i++) { ia[i] = byteString.charCodeAt(i); } const blob = new Blob([ab], { type: mimeString }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = "image." + mimeString.split("/")[1]; a.click();Run this in your browser’s console to download the image directly. The code handles both prefixed and non-prefixed strings.
What to do after decoding the image
Once you have decoded the Base64 string and saved the image as a file, you can:
- View it: Open the file in any image viewer or browser by double-clicking it.
- Edit it: Use tools like Photoshop, GIMP, or even online editors to crop, resize, or apply filters.
- Upload it: Transfer the file to a cloud service, social media platform, or your own website.
- Convert it: Change the format from JPG to PNG or vice versa using tools like Text To HEX or dedicated image converters.
- Verify it: Check the file’s properties to confirm its dimensions, file size, and MIME type match what you expected.
If the decoded image does not look correct, double-check the original Base64 string for missing characters or extra whitespace. A single incorrect character can corrupt the entire file. The Base64 Encode / Decode tool will flag any invalid input so you can fix it before saving the output.