Convert an Image to Base64
Drop any image and instantly copy its Base64 string, data URI, or ready CSS/HTML snippet — free and right in your browser.
Drop an image to encode
Drag & drop, paste, or pick a file
PNG · JPG · WebP · GIF · SVG — encoded on your device
Why convert an image to Base64?
Base64 turns an image's binary data into plain text, so you can paste it directly into code instead of linking to a separate file. It's the standard way to inline a small icon, logo, or background into a CSS file, an HTML email, a JSON payload, or a data URI — removing one extra network request and keeping everything self-contained.
This tool reads your file in the browser and shows the exact Base64 representation of the original bytes — no re-compression, no quality change. You get the raw Base64 body, the full data:image/…;base64 URI, and ready-to-paste CSS and HTML snippets, each with a one-tap copy and a .txt download.
How to convert an image to Base64
- Open your image. Drag a PNG, JPG, WebP, GIF, or SVG onto the tool above, choose a file, or paste from your clipboard.
- Pick the output you need. Switch between the raw Base64 string, the full data URI, a CSS background-image rule, or an <img> tag.
- Copy or download. Tap Copy to put it on your clipboard, or download the string as a .txt file.
Keep inline images small
Base64 adds about a third to the byte size, so inlining is best for small assets — icons, sprites, tiny logos. For large photos, a normal file or URL stays smaller and the browser can cache it separately.
Image to Base64: how it works
Base64 is a text encoding that represents an image's raw binary bytes using only 64 printable ASCII characters (A–Z, a–z, 0–9, + and /), so the file can travel safely through text-only places like source code, JSON, or email.
- Data URI shape
-
data:image/png;base64,iVBORw0KGgoAAAANSUhEUg… - Size impact
- Base64 turns every 3 bytes into 4 characters, so the encoded text is about 133% of the original file — a roughly one-third (~33%) size increase, before the short data:…;base64, prefix is added.
When inlining as Base64 makes sense
- You want to inline a small icon, logo, or sprite directly in a CSS or HTML file so the browser makes no extra HTTP request for it.
- You need the image to live inside a single text artifact — a JSON or YAML payload, an HTML email, a config file, or a copy-paste snippet.
- An API or webhook expects image data as a string field rather than a separate file upload.
When a normal file or URL is better
- The image is large (a photo or hero image): the ~33% overhead bloats your HTML/CSS and the bytes are parsed on every page load.
- The image is reused across many pages: a normal file URL is cached once by the browser, while an inlined copy is re-downloaded inside every file that embeds it.
- The asset changes often: editing an inlined Base64 blob means redeploying the whole file that contains it.
Practical tip
A widely used rule of thumb is to inline only assets under ~1–2 KB; above that, a cached external file usually loads faster than the inlined, un-cacheable Base64 version.
More Base64 & data URI tools
Frequently asked questions
Does converting to Base64 lose quality?
No. Base64 is a lossless text encoding of the exact original file bytes, so the image is unchanged. Decoding gives back a byte-for-byte identical file.
What's the difference between the Base64 and the data URI?
The raw Base64 is just the encoded body. The data URI adds the data:image/…;base64, prefix so a browser can use the string directly as an image source.
Which formats can I encode?
PNG, JPG, WebP, GIF, BMP, SVG, AVIF, and ICO. The data URI's media type matches the file you opened.
Where is my image processed?
The encoding and decoding happen in your browser, so the result is created on your own device. How any data associated with the tool is handled is described in our privacy policy.
More image tools
Crop an image
Crop to any ratio or an exact pixel size.
Image toolCompress an image
Shrink file size without visible quality loss.
Image toolResize an image
Change dimensions to exact pixels or presets.
Image toolConvert HEIC to JPG
Turn iPhone HEIC photos into universal JPG.
Image toolConvert image format
PNG, JPG and WebP — convert any to any.