100% local processing — your files and data never leave this browser. No uploads, no server storage.

OnboxTools

Free · Browser-only · No upload

Image to Base64

Encode images as Base64 strings or raw data

Embed small images directly in HTML, CSS, or JSON by converting them to Base64 text. Choose between a full data URI with MIME prefix or raw Base64 only.

Optional line wrapping helps when pasting into PEM-style documents or email. Encoding runs entirely in your browser — the file never uploads.

Converter controls

Base64 to Image

Prepend data URI prefix (data:image/... or data:application/pdf;base64,...).

Input File

Drag & Drop or Click to Select

Base64 Result
Original Weight0.0 KB
Output Chars0
MIME TypeN/A

More Image Tools

🖼️
Base64 to Image
🎨
Color Format
🎨
Color Picker
🖼️
Data URI to Image
🖼️
Image Compressor
🖼️
Image Resizer
🧬
Image to Base64
🔗
Image to Data URI
🖼️
JPEG to WebP
🖼️
JPG to PNG
🔄
PNG to GIF
🔄
PNG to JPG
PNG Transparency Creator
🖼️
SVG to PNG
🔄
WebP to PNG

Browse by category

Encoding example

A 1.2 KB favicon PNG might produce roughly 1.6 KB of Base64 text — manageable inline in HTML. A 800 KB photo becomes over 1 MB of text and should stay a linked file instead.

Raw Base64 without prefix suits POST bodies like { "image": "iVBORw0KGgo..." } alongside a mime field set to image/png.

Base64 output formats

FromToResult
Data URIIncludesdata:image/png;base64,...
Raw Base64IncludesEncoded bytes only
76-char linesUse whenRFC 2045 consumers
Single lineUse whenJSON, compact storage

Complete guide to image Base64 encoding

What Base64 encoding does

Binary image data cannot travel safely through text-only channels — JSON payloads, XML, CSS url() values, and database text fields. Base64 represents every three bytes as four ASCII characters from a safe alphabet. Decoders reconstruct the original bytes on the other side.

An image encoded as Base64 grows roughly 33% compared to the binary file. That overhead is acceptable for tiny icons and tracking pixels but expensive for large photos.

Configuration files, serverless function bundles, and mobile app JSON sometimes embed small images as text for portability. Base64 keeps those payloads self-contained when a separate image URL is awkward or blocked by offline-first packaging constraints.

Treat encoded strings like source code: review diffs carefully because a one-character typo breaks the entire image at runtime.

Data URI vs raw Base64

A data URI includes the MIME type prefix: data:image/png;base64,iVBORw0KGgo.... Browsers and CSS can consume this directly in img src or background-image without a separate file request.

Raw Base64 omits the prefix — just the encoded payload. APIs and backend systems often expect raw strings and prepend metadata themselves. Toggle the output mode to match your destination.

Pasting the wrong mode into your stack causes silent failures — HTML expects the full data URI, while many REST handlers want raw payload plus a separate contentType field. Copy from the tool in the mode your consumer documents and test one round trip before bulk encoding.

Automated tests can assert that decoded bytes match a golden file hash — encode here once to build that fixture.

When inline Base64 makes sense

Use Base64 for small assets — icons under a few kilobytes, spinner graphics, or single-use email images where external hosting is blocked. Critical CSS sometimes inlines tiny logos to eliminate render-blocking requests.

Avoid Base64 for large hero images. External files benefit from caching, CDN delivery, and parallel downloads. A 200 KB Base64 string bloats HTML and cannot be cached separately.

A practical rule: if the binary file is already larger than a few kilobytes, link it normally. Inlined strings inflate HTML weight and bypass browser cache for that asset. Measure total document size after inlining several icons in critical CSS.

SPAs that bundle icons as Base64 should tree-shake unused strings during build so dead assets do not ship to every user.

Progressive web apps caching HTML should remember that inlined Base64 bypasses the image cache API entirely.

Line wrapping options

Standard Base64 is one continuous string. Some systems expect lines broken every 76 characters — RFC 2045 style — for readability in logs or compatibility with older parsers. Enable split lines and set the length when your target format requires it.

Copy buttons should grab exactly what your downstream tool expects. Test paste into the actual consumer before production.

Email MIME parts and some legacy Java parsers reject unwrapped megabyte strings. JSON and most modern APIs prefer a single line. Match the wrapping setting to your destination spec rather than guessing from habit.

Very long single-line strings can freeze older text editors — use split lines when pasting into human-reviewed config files.

Security and privacy

Encoding happens with FileReader in your browser. Sensitive diagrams, signatures, and ID scans never touch a remote server. Clear the page when finished; encoded strings in clipboard history are your responsibility.

Base64 is encoding, not encryption. Anyone who sees the string can decode the image. Do not treat Base64 as protection for confidential content.

Because encoding runs only in your browser, unreleased wireframes and personal documents are not uploaded to a third party. That local processing helps compliance-sensitive workflows. Still treat copied Base64 like any secret paste — clear clipboard history on shared machines when finished.

Incident response playbooks should remind staff that Base64 in chat logs is still sensitive image data, not redacted text.

Common integration patterns

In HTML: img src equals the data URI. In CSS: background-image url with the same URI. In JSON APIs: a field holding raw Base64 with a separate contentType property.

Keep originals as files for maintainability. Regenerate Base64 when the source image changes rather than editing the string manually.

Version-control the source PNG or SVG, not the encoded string. Scripts can regenerate Base64 in CI when icons change. Hand-editing long strings is error-prone and hides which asset version shipped.

Add a short comment in HTML or CSS pointing to the source filename above the data URI so the next developer knows what to regenerate.

Unicode in filenames does not affect encoding — only the binary image bytes matter in the output string.

Detailed guide

Inlining icons in CSS

Encode a small SVG or PNG, paste the data URI into background-image, and set background-size. Keeps HTTP requests low for critical above-the-fold styles.

Avoiding size pitfalls

If the Base64 string exceeds a few kilobytes, reconsider external hosting. Measure HTML weight after inlining — PageSpeed penalizes enormous documents.

Common questions

Image to Base64 FAQ

Is the Image to Base64 encoder private?

Yes. Everything runs in your browser. Your input is not uploaded, logged, or stored on our servers.

Do I need an account?

No account or sign-up is required. Open the page and start using the tool immediately.

Does Base64 encryption protect my image?

No. Base64 is reversible encoding, not encryption. Anyone with the string can decode it.

Why is the output longer than the file?

Base64 expands binary data by about 33% due to how bits map to text characters.

Should I use data URI or raw Base64?

Use data URI for HTML and CSS. Use raw Base64 when your API expects only the payload without a prefix.

Is there a file size limit?

Very large files may slow the browser or exceed memory limits. Practical use stays under a few hundred kilobytes.