Image to Base64
Encode any image to a Base64 data URI, raw payload, CSS background, HTML tag, or Markdown — entirely in your browser.
Source
Encoded
Choose or drop an image and its Base64 encoding appears here.
About Base64 image encoding
Base64 rewrites arbitrary binary data using only 64 printable ASCII characters (A–Z, a–z, 0–9, + and /). It reads the file three bytes at a time — 24 bits — and splits them into four 6-bit groups, each mapped to one character. Three bytes in, four characters out, so the payload always grows by exactly one third. When the file length is not a multiple of three, the final group is padded with = so the output stays a multiple of four. A data URI adds a little more on top: the data:image/png;base64, prefix.
When inlining is worth it
- Tiny assets — icons, spinners, 1×1 spacers, gradient stops — where the HTTP request costs more than the bytes.
- Critical above-the-fold CSS that must paint without a second round trip.
- Single-file deliverables: email templates, exported reports, offline HTML, embedded documentation.
- JSON or database columns where a binary blob would be awkward to carry.
When it hurts
- A data URI is not a separate cacheable resource. It is re-downloaded with every copy of the HTML or CSS that contains it, and it cannot be served from a CDN edge on its own.
- Inlined bytes sit in the parse path. Large data URIs in a stylesheet delay first paint because the whole file must be parsed before any rule applies.
- Compression helps less than you would hope: gzip and Brotli work poorly on already-compressed image data expanded into ASCII.
- Photographs and anything over a few kilobytes are almost always better as a normal cached request over HTTP/2 or HTTP/3.
SVG is a special case. It is already text, so Base64 buys nothing and costs 33%. Paste the markup straight into the document, or percent-encode it for CSS with url("data:image/svg+xml,..."). URL-encoding usually produces a shorter string than Base64 and stays readable and diff-friendly.
Base64 is encoding, not encryption. Anyone can decode it in one line. Never use it to hide credentials, tokens, or private imagery — it only makes bytes safe to travel through text-only channels.