Image to Base64 Converter

Updated July 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 ↗

Related tools

What Is My Browser?

Detect your browser, OS, screen resolution, window size and more.

Chmod Calculator

Convert file permissions between octal , symbolic and the chmod command.

Password Strength Checker

Estimate password entropy and crack time, entirely in your browser.

UTM Link Builder

Build campaign tracking URLs with UTM parameters for Google Analytics.

Meta Tag Generator

Generate HTML meta, Open Graph and Twitter Card tags for any page.

HTTP Status Codes

Searchable reference of every HTTP status code and what it means.

Data Transfer Rate Converter

Convert between Mbps, MB/s, Gbps and more, with the bits-vs-bytes rule.

ASCII Table

Full ASCII table with decimal, hex, octal, binary and character lookup.

MIME Types

Look up the MIME type for any file extension.

Markdown Table Generator

Build a Markdown table with alignment and copy the syntax, in your browser.

HTTP Headers Reference

Searchable reference of common HTTP request and response headers.

HTML Symbols & Entities

Searchable reference of HTML symbols and entity codes to copy.

Browse all 251 free tools →