Image Tools

Image to Base64

This free Image to Base64 converter turns a JPG, PNG, GIF, SVG or WebP image into a complete Base64 data URI (data:image/...;base64,...) that you can paste into HTML, CSS or JSON. Encoding runs in your browser with the FileReader API, so the image is never uploaded, and you get a live preview and the data URI size in KB.

Runs in your browser. Your files and text never leave your device - nothing is uploaded.

Click or drag an image here
JPG, PNG, GIF, SVG, WebP

Convert an Image to Base64 Online

The Tools Kit’s free Image to Base64 converter turns a JPG, PNG, GIF, SVG or WebP file into a Base64 data URI: a single line of text that starts with data:image/png;base64, (or the type that matches your file) and contains the whole image. You can paste it into an HTML img tag, a CSS background or a JSON value, and the browser will display the picture without loading a separate file.

The image is encoded on your own device with the browser’s FileReader API. Nothing is uploaded, there is no account, and the result appears the moment you add a file, along with a preview drawn from the encoded string and its size in KB. It is one of several browser-based image tools on the site.

How to Use the Image to Base64 Converter

  1. 1

    Add your image

    Click the box labeled "Click or drag an image here" to pick a file, or drag one image onto it. JPG, PNG, GIF, SVG and WebP all work.

  2. 2

    Check the preview and size

    The image is encoded instantly in your browser. A thumbnail rendered from the encoded string appears, and the label above the output shows the data URI size in KB.

  3. 3

    Copy the data URI

    Press Copy Base64 to put the complete data:image/...;base64,... string on your clipboard, ready to paste into an img src, a CSS url() or a JSON value.

  4. 4

    Clear and repeat

    Press Clear to remove the result, then add the next image you want to convert.

The tool converts one image at a time. If you drop several files together, only the first is encoded, and files that are not images (a PDF, for example) are rejected with a message.

What a Base64 Image Data URI Looks Like

Every result has the same three parts: the data: scheme, the image’s MIME type followed by ;base64, and then a comma and the encoded bytes. A PNG begins data:image/png;base64,iVBORw0KGgo, a JPEG begins data:image/jpeg;base64,/9j/, and an SVG begins data:image/svg+xml;base64,. The MIME type comes from the file you choose, so the browser knows how to decode the data later.

The output always includes that prefix, because that is what HTML and CSS need. If a system asks for raw Base64 only, such as some API fields, delete everything up to and including the comma. For encoding plain text rather than an image, use the Base64 encoder, and to turn a Base64 text string back into readable text, use the Base64 decoder.

How Big Is a Base64 Image? The 33% Rule

Base64 writes every 3 bytes of the file as 4 text characters, so the encoded data is about a third larger than the image: Base64 length = 4 × (file bytes ÷ 3), rounded up. The data URI prefix adds a few more characters, 22 for data:image/png;base64,.

  • 1,500-byte PNG icon: 2,000 Base64 characters + 22 = 2,022 characters, shown as 2 KB.
  • 3,000-byte PNG logo: 4,000 characters + 22 = 4,022 characters, shown as 4 KB.
  • 10,240-byte (10 KB) JPEG: 13,656 characters + 23 = 13,679 characters, shown as 13 KB.

The KB figure above the output is the length of the whole data URI divided by 1,024 and rounded, which is roughly how much the string will add to your HTML or CSS. To keep that number small, run large pictures through the image resizer and the image compressor before encoding, or switch to a more compact format with the PNG to WebP converter.

When to Use Base64 Images, and When Not To

Inlining an image saves a separate network request and keeps everything in one file, which is useful for small icons, a logo in a single self-contained HTML page, a placeholder image in a stylesheet, or an image stored inside a JSON configuration. The cost is size and caching: the encoded string is about 33% larger, it cannot be cached on its own, and it is downloaded again whenever the HTML or CSS that contains it changes.

As a rule of thumb, use Base64 for small, rarely changing assets and keep photos as regular files. Before you encode a photo, remember that its metadata (camera details and sometimes GPS location) is encoded along with it; the EXIF remover strips that first. For browser tab icons, the favicon generator produces correctly sized PNG files, and an SVG you would rather ship as a bitmap can go through the SVG to PNG converter first.

Common uses

  • Embedding a small icon in CSS as background-image: url("data:image/png;base64,...")
  • Putting an image straight into an HTML img src for a single-file page, demo or prototype
  • Storing a logo or avatar as a string in a JSON file, config or test fixture
  • Inlining an SVG or PNG placeholder while the full image loads
  • Checking how large an image will be once inlined before deciding whether to link it instead

Image to Base64 terms explained

TermWhat it means here
Base64A way of writing binary data using 64 text-safe characters (A-Z, a-z, 0-9, + and /), with = used as padding
Data URIA URL that carries the file itself instead of pointing to it, in the form data:<MIME type>;base64,<data>
MIME typeThe label that tells the browser what the data is, such as image/png, image/jpeg, image/gif, image/webp or image/svg+xml
Padding (=)One or two = signs at the end of a Base64 string when the byte count is not a multiple of 3
InliningPlacing an asset directly inside HTML, CSS or JSON rather than loading it as a separate file
OverheadThe extra size Base64 adds: every 3 bytes of the image become 4 characters, about 33% more

Frequently Asked Questions

Reviewed by Raja Jahangir · Last reviewed: October 7, 2026

How do you convert an image to a Base64 data URI?

To convert an image to Base64, drop a JPG, PNG, GIF, SVG or WebP file and the complete data URI appears instantly, starting with data:image/png;base64, or the matching type, with its size shown in KB. Copy it straight into an img src attribute or a CSS background. Encoding runs in the browser and adds about 33% to the size.

When should you use a Base64 image instead of a file?

Inline Base64 suits tiny images such as icons and tracking pixels under roughly 2 KB, where saving an HTTP request outweighs the 33% size overhead. For anything larger, a normal image file is better: it can be cached separately, compressed by the server, and lazy-loaded, whereas Base64 bloats the HTML or CSS on every page load.

Sources and standards

Guides for Image to Base64