# Image to Base64

> Convert any image file to a Base64 encoded data URL for embedding directly in CSS, HTML, or JavaScript code.

- Open the tool: https://overtooled.com/image-to-base64
- Category: Image Tools
- Privacy: Runs entirely in your browser. Nothing is uploaded, no account is needed, and it works offline once loaded.
- Price: free, no sign-up
- Keywords: image, base64, convert, data url, css

## In short

Convert any image file to a Base64 data URI for embedding in CSS or HTML.

## Overview

Reads an image file with FileReader.readAsDataURL and shows its Base64 encoding in four ready-to-paste forms. The original file bytes are encoded as-is (no re-encoding), so the MIME type and file contents are kept exactly.

## Features

- Four outputs: raw Base64 string, full data URL, CSS background-image declaration, HTML <img> tag (alt = file name without extension, HTML-escaped)
- Copy button on each output; the raw Base64 output can also be sent on to another tool
- Shows original size vs encoded size in KB
- Image preview
- Drag-and-drop, click, or keyboard (Enter/Space on the drop zone) to browse

## How to use it

1. Drop an image or click to browse
2. Copy the format you need: Base64, data URL, CSS, or <img> tag
3. Click Clear to start over

## Inputs

- Any file whose MIME type starts with image/; one file at a time
- No size cap

## Outputs

- Text only, copied to the clipboard; no file download
- Output previews are truncated at 500 characters on screen, but Copy copies the full string

## Limits and notes

- Non-image files are rejected with an error message under the drop zone
- Large images give very long strings; Base64 is about 33% bigger than the file
- Nothing is stored locally

## Questions and answers

### How does the Image to Base64 Converter work?

The tool reads your image file in the browser with FileReader.readAsDataURL(), which Base64-encodes the original file bytes unchanged and adds the data: prefix with the file's own MIME type. From that data URL it shows the raw Base64 string, the full data URL, a CSS background-image declaration and an HTML img tag, each with a copy button. The file is never re-encoded or uploaded.

### Why would I convert an image to Base64?

Base64-encoded images can be embedded directly in HTML, CSS, or JavaScript without a separate file request. This is useful for small icons, email templates, and reducing HTTP requests on websites.

### Does Base64 make the image larger?

Yes, approximately 33% larger than the original file. This is why Base64 embedding is best for small images (under 10KB). For larger images, serving them as separate files is more efficient.

### What image formats can I convert?

JPG, PNG, GIF, WebP, SVG, BMP, and ICO files. The tool outputs a complete data URL string ready to paste into your code.

## Related tools

- [Image Converter](https://overtooled.com/image-converter.md): Convert images to JPG, PNG, WebP, or JPEG XL instantly in your browser
- [Image to ASCII Art](https://overtooled.com/image-to-ascii.md): Convert images into ASCII art with adjustable width and character sets
- [SVG to PNG Converter](https://overtooled.com/svg-to-png.md): Convert SVG vector graphics to PNG raster images at any size
- [Color Palette Extractor](https://overtooled.com/color-palette-extractor.md): Extract dominant colors from any image as HEX codes

---
Overtooled: 179 free tools that run in your browser. Index of all tools: https://overtooled.com/llms.txt
