Image to Base64
Convert images to Base64 online: get a data URI, raw Base64, an <img> tag or CSS background for PNG, JPEG, SVG, WebP or GIF. Files stay in your browser.
Something not working, or missing a feature? Send feedback
About the Image to Base64
The Image to Base64 converter turns a PNG, JPEG, SVG, WebP, GIF or AVIF file into Base64 text you can embed directly in HTML, CSS, JSON or Markdown. You get a ready-made data URI, the raw Base64, an <img> tag and a CSS background rule, and the image never leaves your browser.
Images are processed in your browser with its built-in codecs, so your photos and screenshots are never uploaded.
How to use the Image to Base64
- Drop an image onto the box, paste it from the clipboard, or choose a file.
- Pick the output you need: data URI, raw Base64, <img> tag, CSS background or Markdown.
- Copy the result into your code. The size line shows how much bigger the Base64 version is.
Common mistakes
- Inlining large images. A 200 KB photo becomes about 270 KB of text inside your HTML or CSS, delays rendering and is downloaded again with every page. Keep data URIs for small icons.
- Forgetting the prefix. Raw Base64 is not a URL. In src or url() you need the full data URI, including data:image/png;base64, at the start.
Works well with the Image to Base64
- Base64 to Image: decode a Base64 image again to check it.
- Base64 Encode / Decode: encode text rather than images.
- CSS Minifier: minify the CSS that contains the data URI.
Frequently asked questions
When should I inline an image as Base64?
For very small images, such as icons under a few kilobytes, in emails, single-file HTML documents or CSS that must not make extra requests. Larger images are better served as files, because Base64 is about 33% bigger and cannot be cached separately.
What is a data URI?
A URL that contains the file itself: data:image/png;base64, followed by the Base64 data. Browsers accept it anywhere an image URL is allowed, such as the src of an <img> or url() in CSS.
Is my image uploaded?
No. The file is read and encoded in your browser with the FileReader API; nothing is sent to a server.
Related tools
Image Compressor
Compress JPEG, PNG and WebP images online with a quality slider and optional resizing. See the size saved for each file. Images never leave your browser.
Image Resizer
Resize images online to exact pixels, a percentage or presets like 1200×630 for Open Graph. Crop to fill, pad or stretch, in batches, without uploading.
Image Cropper
Crop images online with a draggable box, fixed ratios like 1:1, 16:9 or 1200×630, or exact pixel values. Save as JPEG, PNG or WebP without uploading.
Image Converter
Convert images online between PNG, JPEG and WebP, and turn SVG into PNG, with quality and size options. Convert several files at once in your browser.
Base64 to Image
Decode a Base64 string or data URI to an image online: preview it, see its type, size and dimensions, and download it as PNG, JPEG, SVG, WebP or GIF.