Base64 Image Encoder and Decoder

Encode images to Base64 or decode Base64 back to images online for free. Make data URIs for CSS and HTML, or download a file. No upload, no signup.

How to use Base64 Image Encoder & Decoder

  1. 1To encode, upload an image and Pixohub returns its Base64 data URI.
  2. 2Copy the data URI and paste it into your CSS, HTML, or JSON.
  3. 3To decode, paste a Base64 string or data URI into the input box.
  4. 4Preview the decoded image and download it as a file.

Features

  • Encodes any image to a ready-to-use Base64 data URI
  • Decodes a pasted Base64 string back into a downloadable image
  • Everything runs in your browser — nothing is uploaded
  • Free, unlimited, no signup, and works on mobile

Encode images to Base64 and decode them back

Base64 is a way of representing binary data — like an image — using only plain text characters. Encoding an image to Base64 lets you embed the picture directly inside a text file such as a stylesheet, an HTML document, or a JSON payload, instead of linking to a separate image file. The encoded output is usually wrapped in a data URI, a string that begins with data:image/png;base64, followed by the encoded bytes, which browsers understand as an inline image anywhere a URL is expected.

This tool works in both directions. On the encode side, you upload an image and Pixohub produces the full Base64 data URI, ready to copy into your code. On the decode side, you paste a Base64 string or a complete data URI, and the tool reconstructs the original image so you can preview it and download it as a proper file. That makes it easy to inspect an inline image you found in some CSS, or to recover a picture that was stored as a string in a database or API response.

All of the work happens locally in your browser. Your images and strings are never sent to a server, so even large or sensitive files are handled privately and instantly. There is no signup, no watermark, and no limit on how many conversions you run.

How to use Base64 Image Encoder & Decoder, step by step

  • Leave the switch on Encode and drop an image onto Drop an image. The file is read as it is, without re-encoding.
  • The full data URI appears under Base64 data URI, with its length in characters next to the label. Check that length before pasting it into CSS or HTML.
  • Press Copy Base64 to copy the whole string, including the data:image/…;base64, prefix.
  • To go the other way, switch to Decode and paste a data URI or raw Base64 text into Paste a data URI or raw Base64 string.
  • Press Decode to image. If the preview shows an error instead of a picture, the text is cut off or is not an image.
  • Press Download image to save the decoded file.

Real example: encoding a PNG and round-tripping a JPG

We encoded Kodak test image 7, a 566,322-byte PNG. The data URI was 755,118 characters: 1.33 times the file size, plus a 22-character data:image/png;base64, prefix. Encoding took about 0.1 seconds.

Then we encoded our 425,116-byte test JPG (566,847 characters), switched to Decode, pasted the string and downloaded the result. The downloaded file had exactly the same bytes as the original JPG (identical MD5 checksum), so nothing was recompressed in either direction.

FileBytesData URI length
Kodak image 7, PNG566,322755,118 characters
Test photo, JPG425,116566,847 characters
JPG after decode425,116 (identical)—

Last updated

Base64 Image Encoder & Decoder compared with other ways to do it

Terminal commands

On macOS and Linux the base64 command encodes a file, and on Windows certutil -encode or PowerShell can do it. They are the best choice in scripts and build steps. They output raw Base64 only, so you add the data:image/…;base64, prefix yourself; this tool adds it with the correct type.

Build tools and bundlers

Web bundlers can inline small images automatically below a size limit you set, which is the better option inside a project that already uses one. This page is for one-off work: an email template, a single HTML file, a JSON fixture or checking what an inline string actually contains.

Upload-based Base64 converters

Online converters do the same encoding but send your image, or the pasted text, to a server first. For screenshots or documents that is worth avoiding. Here the file is read and the string decoded by your browser, and the decoded bytes in our test matched the original exactly.

When to inline images with Base64

Embedding an image as Base64 has real advantages in the right situation. Because the image travels inside the HTML or CSS itself, the browser does not need to make a separate network request to fetch it, which can eliminate a round trip for small, critical assets like an icon or a background pattern. It also makes a snippet fully self-contained: a single HTML file with inline images works with no external dependencies, which is handy for email templates, embedded documentation, or offline demos.

There is a trade-off to keep in mind. Base64 encoding increases the data size by roughly a third compared to the raw binary, and inlined images cannot be cached separately by the browser the way a linked file can. For that reason, inlining is best reserved for small images that appear on nearly every page. Large photos are almost always better served as normal linked files so they can be cached and loaded lazily.

As a practical rule, reach for Base64 when the asset is tiny and ubiquitous, or when you specifically need a self-contained file with no external requests. For everything else, a regular image URL is usually the better choice. This tool makes it easy to experiment either way — encode a candidate image, drop the data URI into your code, and see how it feels before committing.

Frequently asked questions

How much longer is the Base64 text than the file?

About a third longer, plus the short prefix. Our 566,322-byte PNG became a 755,118-character string. Gzip on the server claws some of that back, but inlining large photos still slows the page that contains them.

Does encoding change or compress my image?

No. The file's bytes are encoded exactly as they are, including any metadata in it, such as EXIF or GPS data in a phone photo. Strip that first with the EXIF remover if the string will be public.

Can I paste Base64 without the data: prefix?

Yes. Raw Base64 is accepted and line breaks are removed. The browser recognises common formats from the bytes themselves, so the preview works for JPG, PNG, GIF or WebP data.

What is a Base64 data URI?

It is a text string that begins with something like data:image/png;base64, followed by the encoded image bytes. Browsers treat it as an inline image, so you can use it anywhere a normal image URL would go.

Can this tool both encode and decode?

Yes. Upload an image to encode it into a Base64 data URI, or paste a Base64 string to decode it back into an image you can preview and download.

Are my images or strings uploaded?

No. Encoding and decoding both run entirely in your browser, so your images and Base64 strings never leave your device.

Does Base64 make the image bigger?

Yes, slightly. Base64 encoding increases the data size by about a third compared to the raw binary, which is why it is best used for small, frequently used images.

When should I inline an image as Base64?

Inlining works well for tiny, ubiquitous assets like icons or for self-contained files such as email templates. Large photos are usually better served as normal linked files that the browser can cache separately.

What formats can I encode?

Any image format your browser can read, including PNG, JPG, WebP, and GIF. The resulting data URI includes the correct MIME type automatically.

Is it free and does it work on mobile?

Yes on both counts. The tool is completely free with no signup and runs in any modern mobile browser.

More text, code & dev tools