Inlining a small icon into CSS
Turn a few-KB icon into a background-image snippet and save an HTTP request.
Guide
Image to Base64 converts in both directions between an image file and its text encoding. Encoding: choose a picture and you get four outputs at once — the complete Data URL (data:image/png;base64,…, ready to drop into src or url()), the bare Base64 without the prefix, a background-image: url('…'); CSS snippet, and an HTML snippet. Each has its own copy button, and the card title shows the encoded size and how much it grew. Decoding: paste a Data URL or bare Base64 and the tool sniffs the header for PNG / JPEG / GIF / WebP / BMP / SVG, then previews and downloads the result. Everything happens locally in the browser.
Updated 2026-09-093 min read
Image to Base64 converts in both directions between an image file and its text encoding. Encoding: choose a picture and you get four outputs at once — the complete Data URL (data:image/png;base64,…, ready to drop into src or url()), the bare Base64 without the prefix, a background-image: url('…'); CSS snippet, and an <img src=… alt=filename /> HTML snippet. Each has its own copy button, and the card title shows the encoded size and how much it grew. Decoding: paste a Data URL or bare Base64 and the tool sniffs the header for PNG / JPEG / GIF / WebP / BMP / SVG, then previews and downloads the result. Everything happens locally in the browser.
The difference from the general-purpose “Base64 Encode / Decode” is that this one is image-aware: it adds the MIME prefix, produces CSS / HTML you can paste straight in, and turns text back into a picture you can look at.
data:image/...;base64,, or bare Base64, into the “Paste Base64” box (whitespace and line breaks are stripped) and click “Decode preview”.base64-image.png.Base64 is about 1.33× the size of the original file
Without a prefix the format is read from the file header
A 12 KB PNG iconData URL about 16 KB (+33%); CSS snippet `background-image: url('data:image/png;base64,iVBOR…');`Paste bare Base64 beginning with `iVBORw0KGgo`Sniffed as image/png, preview shown, downloaded as `.png`Paste a string cut in half“Decode failed: not valid Base64 content, check that the string is complete”data:image/svg+xml;base64,…; the URL-encoded inline form is not producedTurn a few-KB icon into a background-image snippet and save an HTTP request.
Convert a signature image into an <img> snippet for an editor that only accepts HTML.
Paste the Base64 field an API returned and see what the picture actually is.
When there is no image host to upload to, write the Data URL straight into the document.
Base64 represents 3 bytes with 4 characters, a fixed expansion of about 33%, and the data: prefix is added on top; large images are not good candidates for inlining.
Yes — all whitespace is removed before decoding.
Browsers cannot display HEIC directly, so the tool converts it to JPEG (quality 0.92) before encoding; the MIME type is image/jpeg.
Encoding and decoding run inside your browser through FileReader and atob; neither the image nor the Base64 text is uploaded to any server.
Updated 2026-09-09
Image to Base64 (data URL / CSS / HTML snippet) and Base64 back to a previewable image