Instant Preview · 9 Formats · Zero Uploads

Image to Base64 Encoder

Drop any image and instantly get a Base64 string, data URI, and ready-to-paste HTML, CSS, and JavaScript snippets. Nothing ever leaves your browser.

PNGJPEGGIF WebPSVGAVIF ICOBMPTIFF
🖼️

Drop an image here or click to browse

Supports PNG, JPEG, GIF, WebP, SVG, AVIF, ICO, BMP, TIFF

PNGJPEGGIF WebPSVGAVIF ICOBMPTIFF
Reading image…
Uploaded image preview
File name
MIME type
Dimensions
Original size
Base64 size
Overhead
Original Base64 (+~33%)
Raw Base64 0 chars
Data URI 0 chars
9
Image Formats
5
Code Snippets
0ms
Server Latency
100%
Private & Secure

Convert an Image to Base64 in Three Steps

No sign-up, no server uploads. Drop, encode, and copy in seconds.

1

Drop or Browse Your Image

Drag any image onto the drop zone or click to open a file picker. PNG, JPEG, GIF, WebP, SVG, AVIF, ICO, BMP, and TIFF are all supported. The file is read locally nothing is sent to any server.

2

Instant Base64 Encoding

The browser reads the image bytes and converts them to a Base64 string using FileReader.readAsDataURL(). The MIME type is auto-detected from the file and used to build a complete data:[mime];base64,… URI.

3

Copy a Snippet or the Raw String

Copy the raw Base64 or full data URI, download as .txt, or switch to the Snippets tab to grab a ready-to-paste <img> tag, CSS background-image, JavaScript Image() object, or React JSX snippet.

Everything You Need to Encode Images

A complete image encoding toolkit with live preview, dimensions, size analysis, and snippet generation.

🖼️

9 Image Formats

Encode PNG, JPEG, GIF, WebP, SVG, AVIF, ICO, BMP, and TIFF. The MIME type is auto-detected from the file and included in the data URI prefix and all generated snippets.

👁

Live Image Preview

After upload, the image is displayed on a checkerboard background (to reveal transparency) alongside its dimensions, MIME type, original file size, Base64 size, and size overhead percentage.

💻

5 Ready Code Snippets

One-click copy for: HTML <img> tag, CSS background-image, JavaScript new Image() object, JavaScript Fetch API blob, and React JSX inline image all pre-filled with your encoded image.

📊

Size Overhead Report

A visual size comparison bar shows the original file size vs. the Base64 output size side by side. The exact overhead percentage is calculated so you can decide whether inline embedding is practical for your use case.

Download Base64 as Text

Download the raw Base64 string or the full data URI as a .txt file. Useful for pasting into configuration files, storing in a database, or sharing the encoded image without an image hosting service.

🔒

100% Private

All encoding uses FileReader.readAsDataURL() a native browser API. Your image bytes never leave your device. Safe for logos, mockups, internal design assets, and confidential imagery.

Image Format Reference

MIME types, extensions, transparency support, and best use cases for all supported image formats.

FormatMIME TypeExtensionTransparencyData URI SupportBest For
📷PNGimage/png.pngYes (alpha)UniversalIcons, logos, UI elements, screenshots
🖼JPEGimage/jpeg.jpg, .jpegNoUniversalPhotos, complex imagery, email thumbnails
🌸GIFimage/gif.gif1-bitUniversalAnimations, simple graphics, legacy icons
🌐WebPimage/webp.webpYes (alpha)Modern browsersModern web images, smaller than PNG/JPEG
🎨SVGimage/svg+xml.svgYesUniversalScalable icons, logos, illustrations
🌟AVIFimage/avif.avifYes (alpha)Chrome, FirefoxNext-gen web images, best compression
🖥ICOimage/x-icon.icoYesMost browsersFavicons, Windows application icons
📹BMPimage/bmp.bmpNoMost browsersLegacy Windows graphics, uncompressed
🖤TIFFimage/tiff.tif, .tiffYesSafari onlyPrint, photography, archival quality

When You Need an Image as Base64

Embedding images as Base64 solves real problems across web development, email, APIs, and app design.

01

Inline Images in HTML & CSS

Small UI elements icons, spinners, decorative dividers, favicons can be embedded directly in HTML as <img src="data:image/png;base64,…"> or in CSS as background-image: url('data:image/png;base64,…'). Eliminates external requests, removes broken image risks, and works fully offline.

02

Email Template Images

Many email clients block externally hosted images by default. Embedding images as Base64 data URIs in your HTML email template ensures they display immediately without requiring the recipient to click "show images." Ideal for logos, signatures, and small decorative images in transactional emails.

03

Self-Contained Single-File Web Pages

When building a truly portable HTML file a report, an offline dashboard, a documentation page encode all images as Base64 and embed them inline. The resulting .html file contains every asset and renders identically on any machine without an internet connection or web server.

04

Image API Payloads & Testing

Computer vision APIs (Google Vision, AWS Rekognition, Azure Computer Vision, OpenAI Vision) accept images as Base64 strings in JSON request bodies. Encode your test image here and paste the Base64 payload directly into your API request, Postman collection, or curl command.

05

Canvas & JavaScript Image Objects

In browser JavaScript, you can create a self-contained Image object without a hosted URL by setting img.src = 'data:image/png;base64,…'. This is used in Canvas 2D drawing, WebGL texture loading, and service worker pre-caching where you need image assets bundled directly in the script.

06

Browser Extension & PWA Assets

Browser extensions and Progressive Web Apps often need to bundle icon sets and UI images without file server access. Encoding images as Base64 and embedding them in the extension's JavaScript or manifest JSON ensures all assets are available immediately, even in Service Worker contexts and manifest icons arrays.

Image to Base64 Encoding Explained

Image files are binary data sequences of bytes representing pixel values, compression metadata, color profiles, and container headers. Base64 encodes this binary data as printable ASCII text by converting every 3 bytes into 4 characters from a 64-character alphabet, producing output approximately 33% larger than the original file.

The browser's FileReader.readAsDataURL() API reads the image file and returns a complete data URI in the format data:[mime-type];base64,[encoded-data]. The MIME type prefix is determined by the browser from the file's actual byte signature not just the file extension ensuring correct rendering even if the extension is wrong.

The resulting data URI can be used directly as the src attribute of an <img> element, as a CSS url() value, as the src of a JavaScript Image object, or stored as a string in JSON, a database, or a configuration file. No server is ever involved.

// Image file → Base64 data URI
 
const reader = new FileReader();
 
reader.onload = (e) => {
  // Full data URI:
  const uri = e.target.result;
  // "data:image/png;base64,iVBOR…"
 
  // Raw Base64 only:
  const b64 = uri.split(',')[1];
 
  // Use as <img> src:
  img.src = uri;
 
  // Use in CSS:
  el.style.backgroundImage
    = `url(${uri})`;
};
 
reader.readAsDataURL(file);

Frequently Asked Questions

Everything you need to know about encoding images to Base64.

Base64 encodes every 3 bytes as 4 ASCII characters, producing output approximately 33% larger than the original binary. A 100 KB PNG becomes roughly 136 KB of Base64 text. This overhead is the unavoidable cost of representing binary data as printable ASCII. For large images, using a hosted URL is more bandwidth-efficient than embedding as Base64. The size bar in the tool shows the exact overhead for your specific image.
There is no hard limit enforced by this tool. However, FileReader.readAsDataURL() holds the entire file and the resulting Base64 string in browser memory simultaneously. For images over 510 MB, the browser tab may slow down noticeably. Base64-encoded images above a few hundred KB also risk hitting browser attribute length limits when used in HTML src or CSS url() values. For large images, a hosted URL is strongly recommended.
No. The entire encoding process uses the browser's native FileReader API. The image bytes are read directly from your local disk into browser memory no network request is made and nothing is sent to any server. The tool works fully offline after the initial page load, making it safe for confidential mockups, internal design assets, and proprietary imagery.
Use the full data URI as the src attribute of an <img> element: <img src="data:image/png;base64,iVBOR…" alt="description">. For background images in CSS: background-image: url('data:image/png;base64,…'). Use the Snippets tab to copy these code blocks pre-filled with your encoded image no manual editing required.
The Base64 size is always about 33% larger than the source file, regardless of format. So the smallest Base64 output comes from the format with the smallest source file for your specific image. For photographic images, WebP and AVIF typically produce the smallest files. For icons and graphics with solid colors, SVG (as vector text) or PNG with indexed color are often most efficient. The tool shows the exact sizes so you can compare formats before choosing one to embed.
Yes. Use the data URI inside a CSS url() function: background-image: url('data:image/png;base64,iVBOR…'). This works for background-image, list-style-image, border-image, content (on pseudo-elements), and CSS cursor properties. The CSS Background snippet in the Snippets tab generates this code pre-filled. Note: very large Base64 strings in CSS can slow down CSS parsing in older browsers.
Yes. In JSX, use the data URI as the src prop of an <img> component: <img src="data:image/png;base64,…" alt="description" />. The React JSX snippet in the Snippets tab also shows how to assign the Base64 string to a variable and import it inline. For larger projects, consider importing the image as a module (handled by webpack/Vite) instead of embedding it as a raw string in JSX.
Not necessarily. SVG is already text-based, so it can be used in a data URI without Base64 encoding using URL-encoding instead: url("data:image/svg+xml,%3Csvg…%3E"). This is often more compact than Base64 for SVGs. However, Base64-encoding SVGs is simpler, works reliably in all contexts, and avoids having to manually URL-encode special characters. This tool generates both the Base64 output and data URI for any SVG you upload.