Free tool · Base64 Image to Base64 converter, and Base64 back to image
Drop in a PNG, JPG, GIF, WebP or SVG and copy it as a Data URI, plain Base64, a CSS background-image rule or an <img> tag that already carries the right width and height. Paste a Base64 string or Data URI to see the picture and download it. The page also shows how much bigger the image gets, so you can decide whether inlining is worth it.
- PNG, JPG, GIF, WebP, SVG
- Size growth and pixel size
- Read in your browser
Image to Base64 / Base64 to image
The sample is a 48 × 48 PNG icon of 337 bytes. Choose your own image, drop it on this box or paste a screenshot (Ctrl+V / ⌘V). To go the other way, switch the direction and paste Base64.
Saved to My tools
Open the free tools page next time and it is right at the top under My tools (stored in this browser only).
You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.
View My toolsWith or without the data:image/…;base64, prefix. Line breaks and missing = are fine.
Image size (bytes)
337
The file as it is on disk.
Base64 characters
452
Without the data: prefix.
Size increase
34.1%
Base64 versus the original file, before gzip.
Pixel size
48 × 48 px
Read from the file header.
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAP1BMVEUkY+wZXfIAAP9ul/EgX+qnwPckSLbR3vslY+v7/P4ZW+pcivAAAAAkY+slZO4/f/8AAAAAAAAAAAAAAAAAAACp2iEfAAAAEHRSTlOUBgH///8H//7///8AS9IE67PNRAAAALFJREFUeNrtlksKwzAQQ2XnU8eR7fvftpN2k6axa5VCN9EiDEQPwWDQgGThnBA+CGk2IwnSM+XQoZzMaoDzCJ2Cd0Rht98IFjAFQYlwWQGygxRgEYAGqH4j/g/E7TP2A3FYTJOQsDy0xgtoLb8L2C+/L2HnuoBX4Hz5daCy/EbCuesCfgIMsToegHHa/tzq4/tbWk3PB1IZj0A0NcdvCgJ6ZcmlKNeuXuzq6aAfJ+L5cwec9kqLSR9iUAAAAABJRU5ErkJggg==For src, url(), Markdown or a JSON field.
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAP1BMVEUkY+wZXfIAAP9ul/EgX+qnwPckSLbR3vslY+v7/P4ZW+pcivAAAAAkY+slZO4/f/8AAAAAAAAAAAAAAAAAAACp2iEfAAAAEHRSTlOUBgH///8H//7///8AS9IE67PNRAAAALFJREFUeNrtlksKwzAQQ2XnU8eR7fvftpN2k6axa5VCN9EiDEQPwWDQgGThnBA+CGk2IwnSM+XQoZzMaoDzCJ2Cd0Rht98IFjAFQYlwWQGygxRgEYAGqH4j/g/E7TP2A3FYTJOQsDy0xgtoLb8L2C+/L2HnuoBX4Hz5daCy/EbCuesCfgIMsToegHHa/tzq4/tbWk3PB1IZj0A0NcdvCgJ6ZcmlKNeuXuzq6aAfJ+L5cwec9kqLSR9iUAAAAABJRU5ErkJggg==No prefix, standard alphabet with padding: what most APIs ask for.
.icon {
width: 48px;
height: 48px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAP1BMVEUkY+wZXfIAAP9ul/EgX+qnwPckSLbR3vslY+v7/P4ZW+pcivAAAAAkY+slZO4/f/8AAAAAAAAAAAAAAAAAAACp2iEfAAAAEHRSTlOUBgH///8H//7///8AS9IE67PNRAAAALFJREFUeNrtlksKwzAQQ2XnU8eR7fvftpN2k6axa5VCN9EiDEQPwWDQgGThnBA+CGk2IwnSM+XQoZzMaoDzCJ2Cd0Rht98IFjAFQYlwWQGygxRgEYAGqH4j/g/E7TP2A3FYTJOQsDy0xgtoLb8L2C+/L2HnuoBX4Hz5daCy/EbCuesCfgIMsToegHHa/tzq4/tbWk3PB1IZj0A0NcdvCgJ6ZcmlKNeuXuzq6aAfJ+L5cwec9kqLSR9iUAAAAABJRU5ErkJggg==");
background-size: contain;
background-repeat: no-repeat;
}Width and height match the image; change the class name to suit.
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAP1BMVEUkY+wZXfIAAP9ul/EgX+qnwPckSLbR3vslY+v7/P4ZW+pcivAAAAAkY+slZO4/f/8AAAAAAAAAAAAAAAAAAACp2iEfAAAAEHRSTlOUBgH///8H//7///8AS9IE67PNRAAAALFJREFUeNrtlksKwzAQQ2XnU8eR7fvftpN2k6axa5VCN9EiDEQPwWDQgGThnBA+CGk2IwnSM+XQoZzMaoDzCJ2Cd0Rht98IFjAFQYlwWQGygxRgEYAGqH4j/g/E7TP2A3FYTJOQsDy0xgtoLb8L2C+/L2HnuoBX4Hz5daCy/EbCuesCfgIMsToegHHa/tzq4/tbWk3PB1IZj0A0NcdvCgJ6ZcmlKNeuXuzq6aAfJ+L5cwec9kqLSR9iUAAAAABJRU5ErkJggg==" width="48" height="48" alt="">width and height stop the layout from jumping while the page loads.
Usually smaller than Base64 for SVG and works in the same places.
Checks
- Notesample.png · image/png · 0.3 KB. Base64 is 34% larger than the file.
Done here? Try these next
Use this tool often? Save it to My tools.Saved to My tools. Find it any time at the top of the free tools page. You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.
Problem or suggestion?Send feedbackChat with support
Version v1.1Updated Update history
NewNew image to Base64 page: Data URI, plain Base64, CSS and an HTML img tag with width and height, a URL-encoded Data URI for SVG, size increase, and Base64 back to an image.
Which snippet to use, and when not to inline
All the outputs hold the same bytes; they differ in the wrapper around them.
- Standard, URL-safe and MIME options
- Image or file to Data URI
- Points to the exact bad character

Data URI
The Base64 with a data:image/png;base64, prefix. Most places that take an image URL accept it: <img src>, CSS url(), a Markdown image.
Plain Base64
The same characters without the prefix. APIs that upload images in a JSON field, such as OCR or vision APIs, usually ask for this form and a separate MIME type.
Size increase
Every 3 bytes become 4 characters, so the text is about 33% larger than the file (34% for the 337-byte sample). With gzip on the page, already-compressed images come back to within 1–3% of their original size.
Width and height
Read from the file header and written into the CSS and the <img> tag. Without them the browser does not know the box size until the image is decoded, and the layout shifts.
Inlining saves a request but the image can no longer be cached on its own: it is downloaded again with every page or stylesheet that contains it. Keep it for small icons and placeholders.
Image in, snippet out
Both directions run in your browser.
-
1
Add the image
Click “Choose image”, drop a file on the box, or copy a screenshot and press Ctrl+V (⌘V on a Mac) anywhere on the page.
-
2
Copy the format you need
Data URI for
srcandurl(); plain Base64 for an API; the CSS rule or<img>tag to paste directly. Each block has its own copy button. -
3
Going back to an image
Switch the direction to “Base64 → image”, paste the string, check the preview and click “Download file”. The file type comes from the data itself.
Base64 length = 4 × ⌈bytes ÷ 3⌉
Base64 (RFC 4648) writes each 3 bytes as 4 characters from a 64-character alphabet and pads the last group with =. A Data URI (RFC 2397) adds a short prefix in front.
- Base64 characters = 4 × ⌈n ÷ 3⌉ for an n-byte file; the 337-byte sample gives 4 × 113 = 452
- Data URI length = prefix + Base64;
data:image/png;base64,is 22 characters - Pixel size comes from the header: PNG IHDR, GIF screen descriptor, JPEG SOF marker, WebP VP8/VP8L/VP8X chunk, SVG width/height or viewBox
- SVG is text, so it can go into a Data URI URL-encoded instead of Base64: only
< > " # %and a few others are escaped
| File | Bytes | Base64 characters | Increase |
|---|---|---|---|
| Sample icon | 337 | 452 | +34.1% |
| 1 KB | 1,024 | 1,368 | +33.6% |
| 10 KB | 10,240 | 13,656 | +33.4% |
| 100 KB | 102,400 | 136,536 | +33.3% |
Inlining a 10 KB photo: what it really costs
A 10,240-byte JPEG, Base64-encoded and served with and without gzip. Gzip sizes were measured with Node’s zlib on incompressible bytes, which is what JPEG and PNG data look like.
| How it is sent | Bytes on the wire | Versus the file | Cached separately? |
|---|---|---|---|
| Separate .jpg file | 10,240 | — | Yes |
| Inline Base64, no compression | 13,656 | +33.4% | No |
| Inline Base64, gzip | 10,363 | +1.2% | No |
With compression the extra bytes are small; the real cost is caching. An inline image is downloaded again on every page that contains it, while a separate file is fetched once. That is why Data URIs suit small, rarely-changing icons, and why large photos are better as files.
Why an inlined image does not show
Most broken Data URIs come from one of these.
Wrong MIME in the prefix
A PNG labelled data:image/jpeg often still shows, but SVG must be image/svg+xml or it will not render. This tool takes the type from the file’s first bytes.
Truncated string
Copying from a log or a database column with a length limit cuts the end off. The decoder notices when the length or the last bits do not add up.
Unencoded # in an SVG Data URI
A raw # in a colour like fill="#2563eb" ends the URL early. The URL-encoded output here escapes it as %23.
Inlining large photos
A 300 KB hero image as Base64 bloats the HTML and blocks rendering until it is parsed. Inline icons; link photos.
Send events as data, not as packed strings
Some setups squeeze event payloads into Base64 so they fit into a URL. With TapCub the script and SDKs send structured events, and the backend can send its own.
Server API
Payments, refunds or any backend job can send a named event with the project Server Key.
Learn moreValidated on arrival
Unexpected event names, missing properties and values of the wrong type are flagged instead of quietly skewing a report.
Learn moreSigned webhooks
Outgoing webhooks carry an HMAC-SHA256 signature and a timestamp; verify the signature before trusting the body.
Learn moreImage to Base64 questions
Still have a question?
Chat with the team behind TapCub — we usually reply within a few hours on business days.
How do I convert an image to Base64?
Choose the image, drop it on the converter or paste a screenshot. The Data URI, plain Base64, CSS rule and <img> tag appear at once, each with a copy button. The file is read by your browser and never uploaded.
How do I convert Base64 back to an image?
Switch the direction to “Base64 → image” and paste the string, with or without the data:image/…;base64, prefix. The image is previewed and can be downloaded with the right extension, which is taken from the data itself.
Why is the Base64 bigger than the image?
Base64 turns every 3 bytes into 4 characters, about 33% more. Gzip or Brotli on the server win most of that back for text that is sent over HTTP, but the inline copy still cannot be cached separately.
Which image formats are supported?
PNG, JPEG, GIF, WebP, AVIF, BMP, ICO and SVG are recognised from their first bytes. Pixel size is read for all of them except AVIF. Files up to 5 MB are accepted.
Should I use Base64 for SVG?
Usually not. SVG is text, so a URL-encoded Data URI such as data:image/svg+xml,%3Csvg… is often shorter and compresses better. When you add an SVG, both versions are shown with their lengths.
Can I use Base64 images in email?
Support is patchy. Some clients show Data URI images, but Gmail does not, so an inline Base64 logo can arrive as a broken image. For email, link a hosted image or attach it with a Content-ID (cid:) reference instead.
Is it safe to convert private images here?
Yes. Conversion happens in your browser, the image is not uploaded, and the page has no share link, so nothing about the image leaves your device.
Is this tool working for you?
Rate it, or tell us what went wrong and what you’d like improved. A person reads every message, and frequent requests go into the next update.
Need help right now?
Chat with our support team, best for urgent problems; you can leave a message when we are offline.
Chat with supportUpdate history
New features, fixes and data refreshes for this tool, newest first.
-
· v1.1
New featureNew image to Base64 page: Data URI, plain Base64, CSS and an HTML img tag with width and height, a URL-encoded Data URI for SVG, size increase, and Base64 back to an image.
-
· v1.0
LaunchedFirst release.
Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates
Recommend this tool in an article or on your site
This tool is free to cite and share. Copy the URL or link below into your article, tutorial or resource page; to write a review, embed a tool or partner with us, get in touch.
https://tapcub.com/tools/base64-encoder-decoder<a href="https://tapcub.com/tools/base64-encoder-decoder">Base64 encoder and decoder - TapCub</a>Collect events without packing them into strings
One async script on the site, SDKs for apps and mini-programs, and a server API for everything that happens in your backend.