Base64 Image Converter
Paste Base64 or a data: URL to preview and download the image, or upload a file to get its Base64. The real format is detected from the bytes, not guessed.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Base64 Image Converter?
The Base64 Image Converter works in both directions. Paste a Base64 string or a full data: URL and click Generate Image to see the picture, its pixel dimensions, its decoded size in bytes and its real MIME type. Or upload an image file and the tool fills the input with that file as a data URL, ready to copy into CSS, HTML, JSON or a test fixture.
The format is read from the file signature inside the data, so a JPEG pasted with a data:image/png prefix is shown and downloaded as a JPEG. PNG, JPEG, GIF, WebP, AVIF, BMP, ICO and SVG are recognised. Input with line breaks, missing padding or the URL-safe alphabet (- and _) is cleaned up before decoding.
Everything happens in your browser tab. Nothing is uploaded, which matters when the string came from a production database or an API response you would rather not paste into a random website.
- Base64 to image and image to Base64 in one place
- Real format detection from file signatures
- Accepts line-wrapped, unpadded and URL-safe Base64
- Exact decoded size and pixel dimensions
- Copy as raw Base64 or as a complete data URL
- Runs in your browser; nothing is uploaded
Updated
How to use the Base64 Image Converter
- Paste a Base64 string or a data:image/...;base64, URL into the Base64 String box, or pick a file with Or Upload Image File.
- Click Generate Image. The preview appears with Dimensions, File Size (exact decoded bytes) and Format (the detected MIME type).
- Click Copy Base64 for the bare Base64 payload, or Copy Data URL for the complete data: URL with the correct MIME type.
- Click Download to save the decoded file. The extension matches the detected format, for example .jpg or .svg.
- Use Clear All to reset the input, preview and file picker.
Worked examples
Decoding the placeholder pixel
Input
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==
Output
Dimensions 1 × 1 px, File Size 70 bytes, Format image/png
The 96 Base64 characters decode to 70 bytes, which is 96 × 3 / 4 minus the two padding characters. The leading iVBORw0KGgo is what the PNG signature 89 50 4E 47 0D 0A 1A 0A looks like in Base64, so any string starting that way is a PNG.
A GIF pasted with the wrong prefix
Input
data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
Output
Format image/gif, File Size 42 bytes, download named base64-image.gif
The bytes start with GIF89a, so the tool ignores the image/png label. Copy Data URL gives you the corrected data:image/gif;base64,... string.
Background and insight
A data URI, defined in RFC 2397 in 1998, packs a whole file into a URL: data:, a media type, an optional ;base64 flag, a comma, then the payload. Base64 itself is specified in RFC 4648. It maps every 3 bytes to 4 characters from a 64-character alphabet, so the encoded form is always about 33% larger than the file, plus = padding when the length is not a multiple of 3.
That overhead is why inlining is a trade-off rather than a free win. A 600-byte icon inlined into CSS saves an HTTP request. A 300 KB hero image inlined into HTML makes the page heavier, cannot be cached separately and blocks parsing for longer. Most build tools, including Vite, only inline assets below a small threshold (4 KB by default in Vite) for exactly this reason.
A common bug is trusting the prefix. Code that writes data:image/png in front of every Base64 blob works by luck for most raster formats, because browsers sniff JPEG and GIF bytes anyway. It fails for SVG, which is text and is never sniffed, and it produces downloads with the wrong extension. Checking the first bytes (89 50 4E 47 for PNG, FF D8 FF for JPEG, GIF8 for GIF) is the reliable way to know what you have.
Common use cases
Checking what an API returned
Paste the avatar or thumbnail field from a JSON response to see the actual image and confirm its format and size.
Inlining small icons
Upload a small SVG or PNG and copy the data URL into a CSS background-image or an img src to avoid an extra request.
Building email and test fixtures
Get a Base64 image for a unit test, a Storybook story or a seed file without writing a script.
Recovering files from logs
Decode a Base64 blob from a log line or database export back into a file you can open.
Tips and limitations
- Keep inlined images small. Above a few kilobytes, a normal file with long cache headers is usually faster.
- SVG is text, so for CSS you can often use a URL-encoded data URI instead of Base64 and save about a quarter of the size.
- If decoding fails with a length error, the string was probably truncated when it was copied. Base64 length can never leave a remainder of 1 when divided by 4.
- The preview uses pixelated rendering so tiny sprites stay crisp when enlarged. Large photos are shown scaled down to fit.
- HEIC and other formats your browser cannot display will decode but not preview. The error message names the detected type.
Sources and further reading
- RFC 2397: The data URL scheme, IETF. Defines data: URIs
- RFC 4648: The Base16, Base32, and Base64 Data Encodings, IETF. The Base64 alphabet and padding
- data: URLs, MDN Web Docs
- Build Options: build.assetsInlineLimit, Vite. The 4 KB default inline threshold
- MIME Sniffing Standard, WHATWG. The byte signatures browsers use to recognise image types
Frequently asked questions
How do I convert a Base64 string back into an image file?
Paste the string into the Base64 String box, click Generate Image, then click Download. The file is saved with the extension of its real format, detected from the first bytes, so a JPEG downloads as .jpg even if the string was labelled image/png.
Why does my Base64 image not display when I use it in HTML?
Most often the data URL has the wrong MIME type or is missing ;base64 before the comma. Browsers forgive a wrong type for JPEG and GIF but not for SVG. Paste the string here and use Copy Data URL to get a version with the correct prefix.
How much bigger is a Base64 image than the original file?
About 33% bigger. Base64 turns every 3 bytes into 4 characters, so a 30 KB PNG becomes roughly 40 KB of text. Gzip or Brotli on the HTML or CSS claws back some of that, but not all.
Should I inline images as data URIs for performance?
Only for very small images, roughly under 4 KB. Inlined images cannot be cached on their own, make the HTML or CSS file larger and are re-downloaded whenever that file changes. For anything bigger, serve a normal file with caching headers.
What is the difference between Base64 and Base64URL for images?
Base64URL swaps + for - and / for _ so the string is safe in URLs and file names, and often drops = padding. Data URIs use standard Base64. This tool accepts either and converts URL-safe input to the standard alphabet before decoding.
Is it safe to paste Base64 images from production data here?
The decoding runs entirely in your browser and the data is never sent to a server. The page only records anonymous usage events such as "convert" or "download", never the image or the string.
Is there an in-depth guide to the Base64 Image Converter?
Yes. “Resize, Convert, Compress: A Practical Order for Web Images” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.