Image to Base64 Converter

Convert images to Base64 strings or data URIs online. Useful for small icons, CSS embeds, HTML previews, and developer workflows.

Free online file converter tool. Works in Chrome Firefox Safari Edge Opera and other modern browsers on Windows macOS Linux Android and iOS. No software installation required. Browser-side processing keeps your file local when supported. Completely free to use with no account needed.

Image to Base64 Converter

Convert images to Base64 data URLs for embedding in HTML and CSS. Decode Base64 back to images. Free and private.

Drop your image here

or click to browse files

Supports JPEG, PNG, WebP, GIF, SVG and more

Base64 Converter Features

Two-way conversion between images and Base64 data URLs.

B64
Image to Base64

Upload any image and instantly receive a full data URL ready to paste into HTML, CSS, or code.

IMG
Base64 to Image

Paste any Base64 data URL to preview the image and download it as a file.

CPY
One-Click Copy

Copy the entire Base64 string to clipboard with a single click.

How to Convert an Image to a Base64 Data URL

  1. Load your image

    Drag an image onto the upload area or click Choose Image to pick a file from your device. The file is read locally in your browser with the FileReader API, so it is never sent to a server.

  2. Copy the generated data URL

    The full data URL appears in the output box along with the original file size and the Base64 string length in characters. Click Copy to place the entire string on your clipboard.

  3. Decode a string back to an image

    Switch to the Base64 to Image tab, paste a data URL or a raw Base64 string, and click Decode Image. The preview renders in the browser and Save Image downloads it using the detected MIME type.

Base64 Data URL vs External Image File

Embedding an image as a Base64 data URL trades an extra network request for added bytes. The comparison below helps you decide when inlining is worth it and when a regular file URL serves you better.

FactorBase64 Data URLExternal Image File
Extra HTTP requestNone, the image travels inside the documentOne request per image
Transfer sizeAbout 33 percent larger than the binaryOriginal binary size
Browser cachingCached only with the host fileCached and reused independently
Best forSmall icons, logos, sprites, inline email imagesPhotos and large or frequently reused images
Where it livesHTML src, CSS background-image, JSON, JSSeparate file referenced by URL
Editing laterReplace the whole stringSwap the file, keep the same URL

Which Mode and Format Should You Use?

Encode an icon for CSS

Use Image to Base64 on a small PNG or SVG, then paste the data URL into a background-image url() value to drop the HTTP request for that asset.

Inline an image in HTML or email

Copy the full data URL and use it as the src of an img element. Keep inlined images small, since some email clients filter very long Base64 strings.

Recover an image from a string

Use Base64 to Image when you have a data URL or raw Base64 from code, an API, or a config file and need to preview or save it as a real file.

Raw Base64 with no header

If your string lacks the data:image prefix, the decoder assumes PNG and adds the header automatically so the preview still renders.

Common Problems and Fixes

Decoding shows Invalid base64 image data

The string is truncated or corrupted, or it is not actually an image. Paste the complete value including every character, and confirm it represents an image format the browser can render.

The saved file has the wrong extension

Save Image names the file from the MIME type in the data URL header. If you pasted raw Base64 with no header, the tool defaults to PNG. Add the correct data:image prefix to control the saved extension.

The Base64 string is far larger than the image

This is expected. Base64 encoding adds roughly 33 percent overhead because it represents binary bytes as ASCII characters. For large images, link to an external file instead of inlining.

Nothing happens when I drop a file

Only image files are accepted. If you dropped a non-image file or a folder, the tool ignores it. Choose a single image such as JPEG, PNG, WebP, GIF, or SVG and try again.

References

  1. Data URLs - MDN Web Docs, Mozilla
  2. FileReader.readAsDataURL() - MDN Web Docs, Mozilla
  3. Base64 - MDN Web Docs, Mozilla
  4. RFC 4648: The Base16, Base32, and Base64 Data Encodings - IETF
  5. RFC 2397: The data URL scheme - IETF
  6. Window.btoa() - MDN Web Docs, Mozilla
  7. MIME types - MDN Web Docs, Mozilla
  8. Image file type and format guide - MDN Web Docs, Mozilla
  9. Web performance - MDN Web Docs, Mozilla