Image to Base64 & Data URI Encoder
Encode any PNG, JPG, WebP, or SVG into Raw Base64, Data URI, CSS background, or HTML img code instantly—100% offline inside your browser.
Four ready-to-paste Base64 output formats
LocalImgTools encodes your image once in browser memory via FileReader.readAsDataURL and lets you switch cleanly between all four developer formats without re-running:
- Data URI (
data:image/...;base64,...): Drop straight into React/Vuesrcprops, Markdown previews, or canvas scripts. - Raw Base64: Clean ASCII payload without any prefix—ready for REST APIs, GraphQL mutations, OpenAI/vision prompts, and SQLite/Postgres storage.
- CSS
background-image: Validbackground-image: url("data:...");declaration ready for inline critical CSS. - HTML
<img>tag: Self-contained<img src="..." alt="...">snippet for single-file HTML emails or portable reports.
Need to verify or reverse an encoded payload? Jump straight to our Base64 to Image Decoder.
Image to Base64 FAQ
What is the difference between Raw Base64 and a Data URI?
Raw Base64 is only the encoded ASCII payload (e.g. iVBORw0KGgo...), used in JSON APIs, database blobs, and email MIME attachments. A Data URI adds the prefix data:image/png;base64, so browsers can render it directly inside HTML <img src="..."> or CSS url("...").
Why is the Base64 string ~33% larger than my original image file?
Base64 maps every 3 binary bytes (24 bits) into 4 printable ASCII characters (6 bits each), adding a fixed ~33% size overhead. Converting to WebP or compressing first reduces that payload dramatically.
When should developers inline Base64 images vs serving external files?
Inline tiny icons, UI glyphs, or email badges under 4 KB–10 KB to eliminate extra HTTP round-trips. Avoid inlining large photos over 32 KB in CSS/HTML because they bloat the critical stylesheet and cannot be cached separately.