Image to Base64

Share:

Convert any image (JPG, PNG, WebP, GIF, SVG) to Base64 instantly. Drag-and-drop or click to upload. Toggle the data URI prefix, copy to clipboard, or download as text. Free.

RT-IMG-003 · Image & File
Your browser is too old for this tool’s interactive features. Please update to Safari 13.1, Chrome or Edge 80, Firefox 74 or newer.

Image to Base64 Tool

Drop your image here or click to browse
JPG, PNG, WebP, GIF, SVG · Max 5 MB
📅 Research current as of 26 Oct 2026 · Sources: RFC 4648 (2006) §4 and §3.1; RFC 2045 (1996) §6.8; RFC 2397 (1998); W3C File API §6.3; MDN, data: URLs — length limitations
Standards, published formulas, and reference data are revised over time — check against a current authoritative source before relying on these figures.
Advertisement
After results · AD-W1 Responsive · Post-tool — peak engagement

How to Use the Converter

1

Drop or upload an image

Drag an image into the drop zone, or click it to browse. JPG, PNG, WebP, GIF and SVG are supported up to 5 MB.

2

Review the preview

The image preview, file size, and Base64 overhead appear immediately so you can verify the file before using its encoding.

3

Toggle the data URI prefix

Keep the prefix on for direct HTML/CSS use; toggle it off if you only need the raw Base64 string.

4

Copy or download

Copy the result to your clipboard or download it as a plain text file for archiving.

About Image to Base64 Encoding

Base64 is a text representation of binary data — an encoding scheme that takes raw bytes (like the contents of a PNG file) and represents them using only 64 printable ASCII characters: A–Z, a–z, 0–9, plus + and /. The trick lets you embed binary content anywhere a text channel exists: inside HTML attributes, CSS files, JSON payloads, email bodies, even SQL columns. The most common use case for images is the data: URI scheme — an image embedded directly as <img src="data:image/png;base64,iVBORw0KGgo…"> rather than referenced by URL. The browser decodes it on the fly and renders the image without making a separate HTTP request.

The encoding is older than its name. Privacy-Enhanced Mail published it as a "printable encoding" in RFC 989 (February 1987); MIME (Multipurpose Internet Mail Extensions) adapted it and called it Base64 in RFC 1341 (June 1992). The current MIME text is RFC 2045 (1996), and RFC 4648 (2006) is the general definition — which is why an email's PDF attachment is Base64 under the hood. The number 64 comes from the math: 6 bits per character (2⁶ = 64), and three bytes (24 bits) of input map cleanly to four characters of output. This 3-to-4 ratio is also why Base64 adds about 33% to the file size — the price you pay for binary-as-text portability. Two things push it a little higher: the last group is always padded out to four characters with =, so a tiny file grows by much more (1 byte becomes 4 characters), and MIME email breaks the text into 76-character lines, which adds a line break every 76 characters — about 37% in all. The output here has no line breaks, as RFC 4648 asks unless another standard calls for them.

Base64 isn't compression — it's the opposite. Three bytes of binary become four characters of text: a third larger, for the convenience of embedding anywhere a string can go.

When to use Base64 (and when not to)

The classic good use cases: tiny icons under 2 KB (sub-tab icons, status pips, inline SVG decorations), critical above-the-fold images on a slow connection (where saving a request is worth a third more bytes), and inline image data in JSON APIs where the client expects everything in one response. The classic bad use cases: any image over ~10 KB (the 33% overhead becomes a real bandwidth cost), images shared across many pages (each page now embeds the same data instead of caching once), and large images on mobile, where the inflated payload costs anyone on a metered plan. Email is its own case: many clients block remote images by default, but data: images are not a reliable fix either — support varies by client — and the usual method is to attach the image and reference it by cid: (RFC 2392).

Why we encode in your browser

This converter uses the browser's FileReader API to read the file as a Base64 data URL — no upload, no network round-trip, no server-side handling. We chose this approach for three reasons. First, privacy: many use cases involve screenshots of internal dashboards, confidential UI mockups, or proprietary design assets where uploading to a third-party converter is a leak risk. Second, speed: client-side encoding is genuinely instant for files up to a few MB. Third, cost: we don't have to pay for the bandwidth or compute. The 5 MB cap is our choice, not a browser limit: a 5 MB image is already a string of almost 7 million characters, far too long to paste anywhere useful. For larger images, host them on your CDN and use a regular URL.

Singapore and Malaysia have strong personal-data protection laws (PDPA in both jurisdictions, plus GDPR if you serve EU users). Anything containing recognisable faces, ID numbers, or personal information should never be uploaded to a third-party encoder. Local-only encoding eliminates that risk entirely.

Three bytes become four characters, and a data URL can hold far more than you should put in one

01

The name came in 1992; the encoding in 1987. MIME named it Base64 in RFC 1341, adapting the "printable encoding" of Privacy-Enhanced Mail (RFC 989). RFC 2045 (1996) is the current MIME text and caps encoded lines at 76 characters.

02

The "64" is literal. 6 bits per character → 2⁶ = 64 possible characters. A–Z (26) + a–z (26) + 0–9 (10) + + and / = 64 exactly. = is padding.

03

3 bytes → 4 characters. That's the conversion ratio. It's also why Base64 inflates output by a third (4/3 ≈ 1.33), before padding and any line breaks.

04

data: URIs were specified in 1998. RFC 2397 defined the data:[<mime-type>][;base64],<data> scheme.

05

Size is not the limit you will hit. MDN puts Chromium's and Firefox's data-URL limit at 512 MB and Safari's at 2048 MB — far beyond anything worth embedding, which is why this tool stops at 5 MB.

06

URL-safe Base64 is a thing. Standard Base64 uses + and /, which need URL encoding (%2B, %2F). URL-safe Base64 (RFC 4648) substitutes - and _ instead — common in JWT tokens.

07

SVGs don't need Base64. Because SVG is already text, you can embed it URL-encoded: <img src="data:image/svg+xml,%3Csvg…">. No Base64 overhead. The 33% bloat is the cost of binary-to-text conversion only.

08

Email is the exception. Many clients block remote images by default, and data: images are not reliably shown either; email usually attaches the image and refers to it with a cid: URL (RFC 2392).

09

Embedded images are not cached separately. A data URL is part of the page or stylesheet it sits in, so an image used on many pages is downloaded again with each one.

10

This converter runs locally. Browser FileReader API, no upload, no server-side processing. Safe for confidential screenshots, internal mockups, and anything PDPA-covered. Open DevTools → Network to check: no request carries your image.

Frequently Asked Questions

  • Base64 is a binary-to-text encoding scheme that represents binary data (like the bytes of a PNG file) using only 64 printable ASCII characters: A–Z, a–z, 0–9, plus + and /. It lets you embed binary content anywhere a text channel exists — HTML attributes, CSS, JSON payloads, email bodies, SQL columns. The most common image use is the data: URI scheme: <img src="data:image/png;base64,...">.
  • Because Base64 encodes 3 binary bytes (24 bits) using 4 ASCII characters (4 × 6 = 24 bits). That 3-to-4 ratio inflates the output by roughly 33%. The last group is always padded to four characters with =, so very small files grow by more — a 1-byte file becomes 4 characters, +300% — and Base64 wrapped into 76-character lines for email grows by about 37% rather than 33%. This tool adds no line breaks, so its output is exactly 4 characters for every 3 bytes, rounded up.
  • It's the data: URI scheme prefix that tells the browser how to interpret the rest of the string. data: declares it's an inline data URL; image/png is the MIME type; base64 signals the encoding. Without this prefix, browsers won't render the data correctly when used in <img src> or CSS url().
  • No. The conversion runs entirely in your browser using the FileReader API. Your image bytes never leave your device. Check it in DevTools → Network: no request carries your image. Safe for screenshots of confidential dashboards, internal design assets, and any image covered by PDPA / GDPR.
  • We cap inputs at 5 MB. That is our limit, not the browser's: a 5 MB image becomes a Base64 string of almost 7 million characters, impractically long to paste or transmit. For larger images, host them on your CDN and use a regular URL — that's almost always more efficient.
  • Three good cases: (1) very small images under 2 KB — sub-tab icons, status pips, inline decorations where the HTTP round-trip costs more than the 33% bloat; (2) a critical above-the-fold image where saving a request matters more than the extra third; (3) JSON APIs that need to return image data alongside other fields in a single response.
  • Avoid Base64 for: any image over ~10 KB (the 33% overhead becomes a real bandwidth tax), images used on many pages (each page embeds a fresh copy instead of caching once), large images on mobile (a metered plan pays for the extra third), and email, where data: images are unreliable — attach the image and use cid: instead.
  • Size is rarely the cause — MDN puts Chromium's and Firefox's data-URL limit at 512 MB and Safari's at 2048 MB. More often the string was cut when pasted, the MIME type does not match the image, or the prefix is missing. Check that the string ends where the tool's output ends and starts with data:image/…;base64,.
  • Standard Base64 (RFC 4648) uses + and / as two of its 64 characters. Both need URL-encoding (%2B, %2F) when used in URLs. URL-safe Base64 substitutes - and _ instead, so the string can be used directly in URLs without further encoding. JWT tokens use URL-safe Base64. This converter outputs standard Base64.
  • Five: PNG, JPEG, GIF, WebP and SVG, up to 5 MB. Other formats, such as BMP or AVIF, are refused with a message. The output is a data: URI with the file's media type — taken from your browser, or from the file extension when your system reports none — so the string is labelled as the image it is. Copy the full string for direct embedding, or turn the prefix off to get just the Base64.
Advertisement
After how-to · AD-W2 Responsive

Method & sources

How it computes

Reads the image with the browser's FileReader.readAsDataURL (no upload) after ImageBase64Kernel checks it is PNG, JPEG, WebP, GIF or SVG and at most 5 MB. Base64 length = 4 × ⌈bytes ÷ 3⌉ with no line breaks (RFC 4648); overhead = (length − bytes) ÷ bytes. The data: URL is labelled with the browser's type, or the extension's when the system reports none (RFC 2397).

What this tool implements

  • RFC 2045 §6.8 (1996): MIME mail wraps Base64 at 76 characters a line, which with CRLF raises the growth to about 37%; the page now says so. RFC 1341 (June 1992) named Base64 and states it was adapted from the Privacy-Enhanced Mail encoding — first published as the "printable encoding" of RFC 989 (February 1987). The page had dated the encoding itself to MIME.
  • W3C File API §6.3: readAsDataURL uses the Blob's type, "Otherwise, return a Data URL without a media-type"; RFC 2397 reads an omitted media type as text/plain. Corrected 2026-10-26: a .svg/.png the system reported with no type was accepted and then labelled as not an image; the kernel now takes the type from the extension.
  • Corrected 2026-10-26: the FAQ said "any image format your browser can read — PNG, JPEG, GIF, WebP, SVG, BMP, AVIF, and others"; the page accepts five and refuses the rest. It said browsers "struggle" beyond 5 MB; MDN gives Chromium and Firefox a 512 MB data-URL limit and Safari 2048 MB, so 5 MB is this page's own cap and is now called that.

Sources

What can make this go out of date

  • None at runtime: the image is read by the browser and nothing is sent anywhere.
  • The browser data-URL limits quoted on the page are MDN's and change with browser releases; re-check them against the MDN page when the stamp's two-year TTL comes round.
Advertisement
Pre-footer · AD-W3 728 × 90