Runs in your browser. Your files and text never leave your device - nothing is uploaded.
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
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
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
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
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 srcfor 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
| Term | What it means here |
|---|---|
| Base64 | A way of writing binary data using 64 text-safe characters (A-Z, a-z, 0-9, + and /), with = used as padding |
| Data URI | A URL that carries the file itself instead of pointing to it, in the form data:<MIME type>;base64,<data> |
| MIME type | The 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 |
| Inlining | Placing an asset directly inside HTML, CSS or JSON rather than loading it as a separate file |
| Overhead | The extra size Base64 adds: every 3 bytes of the image become 4 characters, about 33% more |
Frequently Asked Questions
Drop a JPG, PNG, GIF, SVG or WebP file onto the upload box, or click it to browse. The tool reads the file in your browser and immediately shows the full Base64 data URI with a preview and its size in KB. Press Copy Base64 to copy it.
A data URI is a URL that contains the file itself instead of a link to it. For an image it looks like data:image/png;base64, followed by the image bytes written as Base64 text. Browsers can display it anywhere a normal image URL is accepted, such as an img src or a CSS background-image.
Yes. The output is always the complete data URI, for example data:image/png;base64,iVBORw0KGgo... with the MIME type that matches your file. If you need only the raw Base64, delete everything up to and including the comma after base64.
About 33% bigger. Base64 turns every 3 bytes into 4 characters, so the length is 4 x (bytes / 3), rounded up. A 3,000-byte PNG becomes 4,000 Base64 characters, plus the 22-character data:image/png;base64, prefix, for 4,022 characters in total.
It is the length of the whole data URI, prefix included, divided by 1,024 and rounded to the nearest whole number. Because each character is one byte of text, it is roughly how much the string adds to your HTML or CSS file. Very small images under about half a kilobyte of output show as 0 KB.
No. The conversion uses the browser FileReader API on your own device, and the tool has no upload step or server endpoint. Your image stays on your computer or phone.
Yes. An SVG file is encoded like any other image and the output starts with data:image/svg+xml;base64,. If you need a bitmap version of the SVG instead, convert it to PNG first and then encode the PNG.
Paste the copied data URI into the src attribute of an img tag: <img src="data:image/png;base64,..." alt="Logo">. Keep the alt text and width and height attributes as you would for a normal image.
Wrap the data URI in url() inside a background-image declaration, for example background-image: url("data:image/png;base64,...");. This is a common way to inline small icons so the stylesheet does not need a separate request.
Avoid it for large photos. The encoded string is about a third bigger than the file, cannot be cached separately from the HTML or CSS that contains it, and has to be downloaded again whenever that file changes. Base64 suits small icons, logos and one-off assets.
No. The tool encodes one image at a time; if you drop several files, only the first is used. Press Clear and add the next image to convert another.
The tool sets no size limit. Very large images produce very long strings, which can make the text box and clipboard slow, so it is best to shrink big images before encoding them.
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.
