Image to Base64: Data URL and raw Base64, both directions

Base64 turns an image into plain text you can paste straight into HTML, CSS, or JSON. This page converts images to Base64 (as a Data URL or raw encoding), restores Base64 back into a downloadable image, and shows the size overhead. Everything runs locally — images are never uploaded.

The two panels below handle "Image → Base64" and "Base64 → Image". Both are ready to use.

Image → Base64

or drop an image here · one at a time

Original size
—
Encoded size
—
Overhead
—

Base64 → Image

When does inlining images as Base64 make sense?

Base64 shines for two jobs: cutting requests and single-file delivery. Embedding a small icon directly in HTML or CSS saves a round trip; embedding an image in an HTML email, a config, or a JSON payload makes the file self-contained with no external dependencies. Photos and large images should stay separate files — browsers cache them better and your text stays manageable.

Rule of thumb: assets of a few dozen KB inline happily. Images over 10 MB produce enormous Base64 text; the tool warns you but won't stop you — judge for yourself.

Data URL vs raw Base64

A Data URL looks like data:image/png;base64,iVBORw0KGgo... — it carries the MIME prefix, so browsers recognize it immediately and it drops straight into <img src> or CSSurl(). Raw Base64 keeps only what comes after the comma; the consumer has to add the prefix or know the type, which is common in API fields, JSON, and databases. Both panels accept either form and strip the prefix automatically.

FAQ

Does converting to Base64 upload my image?

No. Encoding and decoding use FileReader and atob inside your browser. Neither the image nor the Base64 text ever leaves your device.

Why is Base64 about 33% larger than the original?

Base64 encodes every 3 bytes as 4 printable characters, so the result is 4/3 of the original size — an unavoidable ~33% overhead built into the encoding itself.

What is the difference between a Data URL and raw Base64?

A Data URL looks like data:image/png;base64,... and carries the MIME prefix, so it drops straight into an img src or CSS url(). Raw Base64 keeps only the encoded part — handy for JSON payloads, API fields, or custom prefixes.

How does Base64-to-image detect the format?

The tool strips any data URL prefix, then inspects the decoded file header magic numbers to identify PNG, JPEG, GIF, or WebP and picks the right download extension — regardless of the MIME type you pasted.

How large can an image be before inlining stops making sense?

Inline only small assets such as icons of a few dozen KB. Images over 10 MB produce enormous Base64 text that can freeze the page; the tool warns you but does not hard-block.

When should I embed images as Base64?

To cut requests for small icons, ship self-contained HTML emails, or embed assets directly in CSS. Photos and large images should stay as separate files so browsers can cache them properly.

Open the Image Compressor to shrink images before inlining