Boneyard Tools

Image to Base64 Converter

Turn an image into a Base64 Data URI you can paste straight into HTML or CSS, without uploading it anywhere. The image is read in your browser and encoded from its original bytes, so the Data URI decodes back to the exact same file. You get the full data URI plus a ready img tag and a CSS background rule, with the encoded size shown so you can judge whether inlining is worth it.

How to convert an image to Base64

  1. Drop an image in, or click to browse. It stays in your browser.
  2. Copy the Base64 Data URI, the img tag, or the CSS background rule.
  3. Paste it into your HTML or stylesheet. No file hosting needed.

Examples

Inline a small icon in CSS

icon.png (a 1 KB icon)
background-image: url("data:image/png;base64,iVBORw0KGgo...");

Frequently asked questions

Is my image uploaded anywhere?

No. The image is read and encoded entirely in your browser, so it never leaves your device. Nothing is sent to a server, which keeps private images private.

Why is the Base64 string larger than my image?

Base64 represents every 3 bytes with 4 text characters, so the encoded string is about 33 percent larger than the original file. That overhead is the trade-off for embedding the image as text.

When should I inline an image as Base64?

Inlining suits tiny, frequently used assets like icons and small backgrounds, where it saves an HTTP request. For larger images it bloats your HTML or CSS and hurts caching, so a normal file URL is usually better.

Does converting change my image quality?

No. This tool encodes the original file bytes without re-compressing or resizing, so decoding the Data URI gives back a byte-for-byte identical image with the same quality.

How do I use the Data URI in HTML or CSS?

Paste the data: string into an img src attribute, or into a CSS url() such as background-image. This tool generates both snippets for you, ready to copy.

Related tools