Image to Base64 Converter

Free image to Base64 converter: turn PNG, JPG, GIF, WebP, SVG or ICO images into a data URI, raw Base64, CSS or HTML snippet, and decode Base64 back to an image.

Image to Base64
Selected image previewNo image yet
File–
Type–
Dimensions–
Original–
Base64–

    Paste a data URI (data:image/png;base64,…) or plain Base64. Line breaks and URL-safe Base64 are accepted.

    Decoded image previewThe decoded image appears here

    Convert Images to Base64 Data URIs

    Base64 turns the bytes of an image into plain text, so you can embed the picture straight into HTML, CSS, JSON or an email template instead of linking to a separate file. This image to Base64 converter gives you the full data URI, the raw Base64 string and ready-made CSS and HTML snippets.

    It also shows how much bigger the encoded version is and warns you when an image is too large to embed sensibly. The second panel works the other way round: paste a Base64 string or data URI to preview the image and download it as a file. Conversion happens in your browser; nothing is uploaded.

    An image file turned into a Base64 data URIphoto.pngdata:image/…Image toBase64

    How to convert an image to Base64

    1. Choose, drop or paste an image. Screenshots can be pasted straight from the clipboard.
    2. Check the size line: it compares the original file with the Base64 text.
    3. Copy the format you need: the data URI for src attributes, raw Base64 for JSON or APIs, the CSS rule for backgrounds, or the complete <img> tag with width and height.
    4. To decode, paste Base64 or a data URI into the second panel and click Download image.

    How Base64 encoding works

    Base64 reads the file three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each group is a number from 0 to 63 that maps to one character of the alphabet A–Z, a–z, 0–9, + and /. If the file length is not a multiple of three, the output is padded with one or two = signs. So every 3 bytes become 4 characters, and the text is about 33% larger than the file.

    A data URI wraps that text with its type: data:image/png;base64,iVBORw0KGgo…. Browsers treat it exactly like a URL, so it works anywhere an image address is accepted. The URL-safe variant from RFC 4648 uses - and _ instead of + and /; the decoder accepts both.

    Base64 size reference

    Original fileBytesBase64 charactersIncrease
    1 KB icon1,0241,368+33.6%
    10 KB logo10,24013,656+33.4%
    100 KB photo102,400136,536+33.3%
    1 MB photo1,048,5761,398,104+33.3%

    Add the short data:image/…;base64, prefix for a data URI. GZIP or Brotli compression on the server recovers part of the overhead for text files that contain Base64.

    When to use Base64 images, and when not

    • Good for: tiny icons, loading spinners and placeholders, single-file HTML reports and demos, images inside JSON or API payloads, and CSS where one less request matters.
    • Not for: photos and large graphics. Embedded images cannot be cached separately, they make the HTML or CSS file larger and they block rendering while that file downloads.
    • Email: many email clients, including Gmail, do not display data URI images. Host the image or attach it with a content ID instead.
    • Shrink first: compress the file with the image compressor, resize it with the image resizer or switch to a smaller format with PNG to WebP before encoding.
    • SVG icons: URL-encoded SVG text is often smaller than Base64. For CSS-only effects, a CSS gradient needs no image at all.
    • Favicons: create real icon files with the favicon generator rather than inline data.

    Frequently Asked Questions

    Common questions about converting images to Base64.

    It is an image file encoded as plain text with the Base64 alphabet. Wrapped in a data URI, it can be used directly in an img src, a CSS url() or a JSON value without a separate file.

    Base64 stores 3 bytes in 4 characters, so the text is about 33% larger than the file, plus a few characters for padding and the data URI prefix.

    Put the data URI in the src attribute: <img src="data:image/png;base64,…" alt="…">. Copy the HTML snippet above, which also includes the width and height.

    Use it inside url(), for example background-image: url("data:image/png;base64,…");. The CSS snippet above is ready to paste.

    Modern browsers accept data URIs of several megabytes in img and CSS, but very long strings slow down parsing and editing. Keep embedded images small, ideally a few kilobytes.

    Yes. Paste the Base64 text or the full data URI into the second panel. The tool detects the format from the data itself, shows a preview and lets you download the file.

    No. Base64 is a lossless text encoding of the exact same bytes. Decoding it gives back an identical file.

    No. The image is read with the FileReader API and encoded in your browser. Nothing is sent to a server.