Image to Base64

Turn an image into Base64 text you can paste into HTML, CSS, JSON or an API request: as a data URI, raw Base64, a CSS rule or an HTML tag.

Your files stay on your device. Nothing is uploaded.

Image to Base64

One image · up to 10 MB

Step 1: Add an image

Drag and drop an image here

or

PNG, JPG, WebP, GIF, SVG, AVIF or BMP. Up to 10 MB.

Step 2: Output format

Format

A data URI (data:image/png;base64,...) works directly in src and url(). Base64 only is the raw code, for APIs and JSON.

Step 3: Encode

How to convert an image to Base64

  1. Add your image

    Click Choose image or drag a PNG, JPG, WebP, GIF, SVG, AVIF or BMP into the box.

  2. Choose the format

    Pick Data URI, Base64 only, CSS background or HTML img tag.

  3. Copy or download

    Click Convert to Base64, then copy the text or download it as a TXT file.

About this tool

What Base64 is

Base64 writes binary data, such as an image, using only 64 safe text characters. That lets an image travel inside text: an HTML page, a CSS file, JSON or an email.

It makes files about a third larger

Base64 text is about 33% larger than the image file. Use it for small icons and images under a few kilobytes; larger images load faster as normal files, which browsers can also cache.

The four formats

Data URI: data:image/png;base64,... for src and url(). Base64 only: the raw code for APIs. CSS: a ready background-image rule. HTML: a ready <img> tag with alt text from the file name.

Privacy

This tool runs in your browser, on your own device. Your files and text are not uploaded to our server and we cannot see them. When you close or reload this tab, they are cleared, along with the results.

Frequently asked questions

Is there a size limit?

Up to 10 MB per image. Very long text can make some editors slow, which is another reason to keep Base64 for small images.

How do I turn Base64 back into an image?

Paste a data URI into your browser's address bar and the image opens; you can then save it.

Is my image uploaded?

No. Everything happens in your browser, so your images never leave your device.

Can I encode text instead of an image?

A Base64 text encoder is planned for the developer tools.