Image to Base64 Converter
Convert images to Base64 data URIs in your browser — PNG, JPG, GIF, WebP, SVG, ICO. Copy HTML, CSS, Markdown & JSON, with the exact size increase. 100% private, no upload.
Drop an image here, paste it, or click to browse
PNG · JPG · GIF · WebP · SVG · ICO · BMP — converted entirely in your browser
What is a Base64 Image (Data URI)?
A Base64 image is a picture whose binary bytes have been re-encoded as a string of printable ASCII characters using the Base64 alphabet (A–Z, a–z, 0–9, + and /). Wrapped in the data: URI scheme — data:image/png;base64,iVBORw0KGgo… — that string can appear anywhere a URL is expected: an HTML img src, a CSS background-image, an email body, or a field inside a JSON payload. The browser decodes it on the fly and displays the image with no separate network request. This is why Base64 images are sometimes called "inline" or "embedded" images.
The encoding exists for a simple reason: many systems were built to carry text, not arbitrary binary. HTML, JSON, email headers, and URLs all expect characters, and raw image bytes would include control codes and delimiters that break them. Base64 maps every 3 binary bytes onto 4 safe text characters, guaranteeing the data survives transport intact. The cost is size: the text representation is about 33% larger than the original binary, and it cannot be cached independently of the document that contains it.
That trade-off defines when Base64 images make sense. For a tiny icon used in one stylesheet, inlining removes a round trip and the size penalty is negligible — a clear win. For a 200 KB hero photo reused across every page, inlining bloats every page, defeats the browser cache, and costs CPU to decode on each load — a clear loss. The modern, HTTP/2-era guidance is to inline only small, stable assets and serve everything else as ordinary cached files. This tool surfaces the exact numbers for your image and a traffic-light recommendation so the decision is grounded in data, not folklore.
The reverse operation — turning a Base64 string back into a viewable, downloadable image — is equally useful when you are debugging a data URI from a stylesheet, inspecting an API response, or recovering an asset embedded in a config file. Switch to the Base64 → Image tab or open the dedicated Base64 to Image decoder.
<!-- The same 1×1 transparent PNG, four ways -->
<!-- HTML -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" alt="pixel">
/* CSS */
.badge {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==");
}
<!-- Markdown -->

// JSON
{ "mime": "image/png", "data": "iVBORw0KGgo…" } Key Features
Drag, Click, or Paste
Three input paths: drop a file, browse to it, or paste an image straight from the clipboard with Ctrl+V — the fastest route for screenshots. Whatever you provide is encoded immediately, with no upload.
Six Output Formats
Raw Base64, a full Data URI, an HTML element, a CSS background-image rule, a Markdown image link, and a JSON object. Each has its own Copy button and a Download option, so the snippet is ready for exactly the context you need it in.
Live Size & Inflation Metrics
The metadata bar shows the original file size, the encoded Base64 size, and the precise percentage increase for your specific image — not a generic "about 33%". You see the real cost of inlining before you commit to it.
Inline Advice Badge
A traffic-light recommendation reads your file size and tells you whether a data URI is a good idea: green under ~2 KB, amber up to ~10 KB, red above. It encodes the post-HTTP/2 consensus so you don't have to remember the thresholds.
Built-in Decoder
The Base64 → Image tab reverses the process: paste a string or data URI and get a live preview, the decoded dimensions and MIME type, and a Download button that rebuilds the original file. It tolerates missing prefixes and stray whitespace.
All Common Formats
PNG, JPG, GIF (animated preserved), WebP, SVG, ICO, and BMP — plus AVIF where supported. The raw bytes are encoded as-is, so transparency, animation, and vector scalability all survive untouched.
Examples
PNG to a Data URI (CSS / HTML ready)
transparent-1x1.png (a 68-byte PNG)
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
Drop a PNG and the Data URI tab gives you a string you can paste straight into an HTML src or a CSS url(). The metadata bar shows the original size, the Base64 size, and the exact percentage increase.
Inline an SVG icon in HTML
icon.svg
<img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0i…" alt="icon">
Switch to the HTML tab for a ready-to-paste element. For SVG specifically, URL-encoding is often smaller than Base64 — see the FAQ on why SVG is a special case.
Markdown image with an embedded JPG
photo.jpg (12 KB)

The Markdown tab produces a self-contained image link — handy for README files, GitHub issues, and notebooks where you cannot host an external file. At 12 KB the advice badge turns amber: weigh the convenience against the page-weight cost.
How to Convert an Image to Base64
- 1
Add your image
Drag an image onto the drop zone, click to browse, or paste from the clipboard with Ctrl+V / Cmd+V. PNG, JPG, GIF, WebP, SVG, ICO, and BMP are all supported and encoded entirely in your browser.
- 2
Pick an output format
Choose Data URI, raw Base64, HTML
, CSS background, Markdown, or JSON from the tabs. Check the metadata bar for the size increase and the advice badge for whether inlining is worth it.
- 3
Copy or download
Click Copy to grab the snippet, or Download to save it as a file. To reverse the process, switch to the Base64 → Image tab, paste a string, and download the reconstructed image.
Common Pitfalls
Missing or Wrong MIME Type
A data URI must declare the correct media type or the browser refuses to render it. Encoding a PNG but labelling it image/jpeg, or omitting the type entirely, produces a broken image. Copy the Data URI or HTML output directly from this tool to get the right prefix automatically.
data:base64,iVBORw0KGgo… <!-- no MIME type — will not render -->
data:image/png;base64,iVBORw0KGgo… <!-- correct: image/png -->
Whitespace or Line Breaks in the String
Some tools wrap Base64 at 76 characters per RFC 2045, and copy-paste can inject stray spaces or newlines. In an HTML attribute or CSS url(), those breaks can invalidate the URI. Strip whitespace before using the string — this tool's decoder does it automatically, so a round-trip through the Base64 → Image tab will clean it.
data:image/png;base64,iVBORw0KGgoAAAANS UhEUgAAAAEAAAABCAYAAAA… <!-- embedded newline breaks the attribute -->
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAA… <!-- single unbroken line -->
Truncated String (Dropped Padding)
Base64 strings end in zero, one, or two = padding characters. A partial copy that drops the trailing = (or the last few characters) yields an undecodable string and a broken image. If a paste fails to render, confirm you copied the entire value including any trailing padding.
…WjR9awAAAABJRU5ErkJggg <!-- missing trailing == -->
…WjR9awAAAABJRU5ErkJggg== <!-- complete with padding -->
Base64-ing a Large Photo
Encoding a multi-hundred-KB photograph produces an enormous string that bloats your HTML or CSS, cannot be cached on its own, and is slow to decode. The advice badge turns red for exactly this case. Serve large images as normal files; reserve Base64 for small assets, and compress first.
/* 380 KB hero photo inlined into a global stylesheet */
.hero { background-image: url("data:image/jpeg;base64,/9j/…(½ MB of text)…"); } /* Serve it as a cached file instead */
.hero { background-image: url("/img/hero.jpg"); } Common Use Cases
- Inline a logo or icon in CSS
- Drop a small PNG or SVG icon, copy the CSS background-image snippet, and paste it into your stylesheet to remove an HTTP request for an asset that rarely changes. Keep it under ~2 KB (watch the green badge) so the stylesheet stays lean.
- Embed images in HTML email
- Email clients often block remote images. Encode your logo as a data URI and paste the
element into the template so it renders without a server fetch. Test across clients — keep embeds to small icons, not photos.
- Self-contained Markdown and READMEs
- When you cannot host an image — a GitHub issue, a notebook, an offline doc — the Markdown output embeds the picture directly in the file so it travels with the text. Ideal for small diagrams and badges.
- Images inside JSON or API payloads
- Need to ship a thumbnail inside a JSON document or a config file? The JSON output gives you a { mime, data } object you can drop straight in, and the decoder recovers the image on the other end.
- Quick data-URI debugging
- Found a mysterious data: URI in a stylesheet or an API response? Paste it into the Base64 → Image tab to see what it actually is, read its real dimensions, and download it as a normal file for closer inspection.
- Single-file widgets and bookmarklets
- Bookmarklets and embeddable widgets must be self-contained with zero external dependencies. Inlining their icons as Base64 keeps everything in one file that works no matter where it is dropped.
Technical Details
- How Base64 Encoding Works
- Base64 takes the image's binary stream three bytes (24 bits) at a time and splits it into four 6-bit groups, each mapped to one character in the 64-symbol alphabet. When the input length is not a multiple of three, one or two = padding characters mark the remainder. This 3-to-4 ratio is why the encoded text is about 33% larger than the source. The tool computes the decoded byte length directly from the string length and padding, so the size figures it reports are exact, not estimated.
- MIME Detection and Magic Bytes
- When you encode a file, its MIME type comes from the browser's File object. When you decode a raw Base64 string with no data: prefix, the tool inspects the leading characters, which correspond to the image's magic bytes: iVBORw0KGgo for PNG, /9j/ for JPEG, R0lGOD for GIF, UklGR for WebP, and PHN2Zy or PD94bWw for SVG. This lets the decoder reconstruct a correct data URI and download with the right file extension even when the input is just the bare payload.
- Local-Only Processing
- Encoding uses the FileReader API's readAsDataURL, which returns a data URI synthesized entirely in the browser. Decoding for download uses atob plus a Uint8Array to rebuild the binary, then a Blob and an object URL — again with no network involved. The result is a tool you can run offline and trust with confidential images, because the bytes never leave the page. You can verify the zero-request behavior in your browser's developer tools.
Best Practices
- Inline Only Small, Stable Assets
- The sweet spot for Base64 is assets under ~2 KB that change rarely and appear on few pages — icons, tiny logos, UI sprites. Above ~10 KB, the size penalty and lost caching outweigh the saved request, especially now that HTTP/2 makes extra requests cheap. Let the advice badge guide you, and serve photos and large graphics as ordinary cached files.
- Prefer URL-Encoding for SVG
- SVG is text, so Base64 inflates it for no gain. When inlining SVG in CSS or HTML, URL-encode the markup instead — it is usually smaller, stays human-readable, and compresses better with gzip/brotli. Reserve Base64 SVG for pipelines that specifically require it. Our URL Encoder/Decoder handles the percent-encoding.
- Always Set the Correct MIME Type
- A data URI renders only if its MIME type matches the content: image/png, image/jpeg, image/gif, image/webp, image/svg+xml. A wrong or missing type is the number-one reason an embedded image fails to display. When you copy from this tool the type is set for you; if you assemble URIs by hand, double-check the prefix.
- Compress Before You Encode
- Since Base64 adds ~33% on top of the file size, shrinking the source first pays off twice. Run images through our Image Compressor — or export at the right dimensions — before encoding, so the resulting data URI is as small as possible. A 4 KB compressed PNG beats a 40 KB original both as a file and inlined.
- Never Rely on Base64 for Privacy
- Base64 is trivially reversible and offers no protection. Do not use it to obscure sensitive image content — anyone can decode it instantly, including with the tab on this page. If content must be protected, use real access controls and encryption on the server, and serve the image through an authenticated endpoint.
Frequently Asked Questions
What does this Image to Base64 converter do?
Are my images uploaded to a server?
How much bigger does Base64 make an image?
When should I use a Base64 image instead of a normal file?
When should I NOT use Base64 images?
How do I use the Base64 output in HTML and CSS?
Which image formats are supported?
Why is SVG a special case?
Is Base64 the same as encryption?
Can I embed a Base64 image in an email?
Why does my Base64 image not render?
Related Tools
View all tools →Base64 Decoder & Encoder
Encoding & Formatting
Decode and encode Base64 online for free. Real-time conversion with full UTF-8 and emoji support. 100% private — runs in your browser. No signup needed.
Base64 to Image Converter
Encoding & Formatting
Decode a Base64 string or data URI back into an image in your browser. Preview, read dimensions & MIME, then download as PNG, JPG, GIF, SVG. No upload.
CSV to JSON Converter
Encoding & Formatting
Convert CSV to JSON in your browser. RFC 4180, type inference, header row, big-int safe. 100% private, no upload.
JSON Diff & Compare
Encoding & Formatting
Compare two JSON files instantly in your browser. Side-by-side highlighting, RFC 6902 JSON Patch output, ignore noisy fields like timestamps and IDs. 100% private, no upload.
JSON Formatter & Validator
Encoding & Formatting
Format, validate and beautify JSON instantly in your browser. Free online tool with syntax validation, error detection, minify and one-click copy. 100% private.
JSON Schema Validator
Encoding & Formatting
Validate JSON against any JSON Schema instantly in your browser. Supports Draft 2020-12, 2019-09, and Draft-07 with path-precise error messages. 100% private — no upload, no account, free.