Image to Base64

Drop an image and get a Base64 data URL you can paste into CSS, HTML, or JSON.
Preview
— Original: — Base64: —
Privacy note: Images are read and encoded entirely in your browser. Nothing is uploaded to a server.

How image Base64 encoding works

Base64 lets binary data — like an image file — be represented as plain text. That's useful when you need to embed an image inside something that only accepts text, like a CSS file, an HTML attribute, or a JSON payload. The tool produces a "data URL": a single string that starts with a MIME type and then contains the entire image as Base64.

The data URL format

data:[mime-type];base64,[base64-encoded-bytes]

For a PNG image, the result starts with data:image/png;base64, followed by the encoded bytes. You can paste this whole string anywhere a URL is expected — into the src attribute of an image tag, into a CSS url(), or into a JSON string value.

How the encoding happens

The browser reads the file as bytes (using the FileReader API), then encodes those bytes as Base64. The result is the same Base64 encoding used by the Encoder tool — the only difference is that the input is an image file instead of plain text. The tool then prepends the data URL prefix based on the file's MIME type.

When to use data URLs — and when not to

Data URLs have real trade-offs:

How large is a Base64 image?

About 33% larger than the original file. A 10 KB PNG becomes roughly 13 KB of Base64 text. A 100 KB JPEG becomes about 133 KB. This is because Base64 uses 4 characters to represent every 3 bytes of binary data, and each character is stored as one byte in the HTML document.

Common questions

← Back to Your Online Helper