Image to Base64 Converter

Updated June 2026

Turn any image into a Base64 data URI you can paste straight into your HTML or CSS. Pick a file or drop one onto the box below — it is read and encoded entirely in your browser, with ready-to-copy img and background-image snippets.

Convert an image to a Base64 data URI you can paste straight into HTML or CSS — no upload, the image is read and encoded entirely in your browser. Great for small icons; large images make big strings, so use sparingly.

Drag & drop an image here, or click to browse.

PNG, JPG, GIF, SVG, WebP — read locally, nothing uploaded.

Everything runs in your browser. Your image is never sent anywhere.
Preview —
Type
—
Size (KB)
—
Base64 (KB)
—

How this image to Base64 converter works

A Base64 data URI packs an entire file into a single text string so you can embed it directly inside your markup instead of linking to a separate file on a server. When you choose an image, this tool uses the browser's FileReader to read the bytes and the readAsDataURL method to return a string that begins with data:, names the image's MIME type, declares ;base64,, and then carries the file's bytes as Base64 text.

Because Base64 represents every 3 bytes of binary as 4 characters of text, the encoded string is about 33% larger than the original file. That trade is worth it for tiny assets — one fewer network request — but quickly becomes counter-productive for big images, which is why this tool warns you when a file is large.

Worked example: a 24×24 PNG icon weighing 1.5 KB encodes to roughly 2.0 KB of Base64 text. Pasted into CSS it looks like background-image: url("data:image/png;base64,iVBORw0KGgo…"); — one rule, no extra HTTP request. The same approach on a 2 MB photo would add ~700 KB of text to your file and is not recommended.

Usage note: in HTML drop the data URI into an <img src="…">; in CSS wrap it in url("…"). Inlined images are not cached separately by the browser, so reuse a normal file reference when the same image appears on many pages.

Use caseInline as Base64?Why
Small UI icons & logosGoodSaves a request; size overhead is tiny.
Images in HTML emailGoodExternal images are often blocked; inlining shows them reliably.
CSS sprites / decorative shapesOKFine for small assets; keep the total string modest.
Large photos & hero imagesBad~33% bloat, no separate caching, slower page parse.
Images reused across many pagesBadA shared file is cached once; inlining duplicates it everywhere.

Frequently asked questions

What is a Base64 data URI?
A data URI embeds a file directly inside HTML or CSS instead of linking to it. For images it looks like data:image/png;base64,iVBORw0… — the prefix names the MIME type and encoding, and the long tail is the file's bytes encoded as Base64 text.
How do I convert an image to Base64?
Pick or drag an image into the tool. Your browser reads the file locally with FileReader and produces a Base64 data URI. Copy the URI, or copy the ready-made img or CSS snippet, and paste it into your code.
When should I inline images as Base64?
Inlining is best for tiny assets — small icons, logos, sprites, or images in HTML emails. Avoid it for large images or photos, where the string bloats your file and is not cached separately.
Does Base64 make images bigger?
Yes — Base64 inflates the data by roughly 33%, because every 3 bytes become 4 text characters. A 30 KB icon becomes about 40 KB of text, so reserve inlining for small files.
Is my image uploaded anywhere?
No. The image is read locally in your browser with the FileReader API and encoded on your device. Nothing is uploaded, so the tool works offline and your image never leaves your computer.
How do I use a data URI in CSS or HTML?
In HTML use the src attribute: <img src="data:image/png;base64,…">. In CSS use it as a background: background-image: url("data:image/png;base64,…"). The tool generates both snippets for you.
⚡ Image to Base64 Converter — by larely ↗

The rest of the workbench

Password Generator

Generate strong, random passwords and passphrases privately in your browser.

Base64 Encoder / Decoder

Encode and decode Base64 text in your browser.

UUID Generator

Generate random version-4 UUIDs, one or in bulk, in your browser.

Text Diff Checker

Compare two texts and highlight the differences line by line.

Hash Generator

Generate SHA-256, SHA-1, SHA-384 and SHA-512 hashes in your browser.

JSON to CSV Converter

Convert a JSON array to CSV and CSV back to JSON.

Image Compressor & Converter

Compress, resize and convert JPEG, PNG and WebP images in your browser — nothing is upl…

File Checksum Calculator

Verify a file's SHA-256, SHA-1, MD5 or CRC32 checksum in your browser — no upload.

AES-256 Text Encryption

Encrypt and decrypt text with password-based AES-256-GCM, entirely client-side.

HMAC Generator & Verifier

Compute and verify HMAC-SHA256 and other HMAC signatures in your browser.

Test Data Generator

Generate fake mock data as CSV or JSON for testing.

More workbench tools →