How-to guide

How to Convert Image to Base64 Online (Free Guide)

Updated 2026-12-041035+ wordsFree tools · no signup

To convert an image to Base64, encode the image file's bytes as text: every 3 bytes become 4 Base64 characters (RFC 4648), so the text is about one-third larger than the file. Wrap that text as a data URL — data:image/png;base64,… — to embed the image directly in HTML or CSS, or use the raw Base64 string for JSON and APIs. The fastest free route is Hellagape's Image to Base64 tool, which encodes in your browser with the Canvas API: nothing is uploaded, and there are no watermarks or daily limits.

How to convert an image to Base64 (step by step)

  1. Open Image to Base64 in your browser.
  2. Drop your image onto the upload area, or click to browse and select the file. The pixels are decoded locally with the Canvas API and never leave your device.
  3. Copy the resulting Base64 data URL. For HTML/CSS embedding, keep the full data:[type];base64, prefix; for JSON/APIs that expect raw Base64, copy only the part after the comma.
  4. Paste it where the image address would go: <img src="data:image/png;base64,…"> in HTML, or background-image: url("data:image/png;base64,…") in CSS.
  5. To go the other way — Base64 back to an image file — use the reverse tool, Base64 to Image.

Note: the live page's generic step text mentions downloading a processed image; the tool's catalogue description is "encode an image as a Base64 data URL for CSS and HTML embedding." Confirm the exact copy/download controls on the live page before publishing this guide.

Worked example: the size maths (verified)

Base64 writes 4 characters for every 3 bytes, so encoded length = 4 × ⌈bytes ÷ 3⌉.

  • A minimal 1×1 transparent PNG is 68 bytes → 4 × ⌈68 ÷ 3⌉ = 92 Base64 characters. With the 22-character data:image/png;base64, prefix, the full data URL is 114 characters.
  • A 1,024-byte image → 1,368 characters (+33.6%), or 1,390 as a PNG data URL.
  • A 10,240-byte image → 13,656 characters (+33.4%).

Rule of thumb: budget file size × 1.34 for the embedded text. That is why Base64 suits small icons and logos, not photographs: a 200 KB photo becomes ~268 KB of text inside your HTML, and it cannot be cached separately.

Raw Base64 vs data URL: which one do you need?

OutputStarts withUse it for
Data URLdata:image/png;base64,iVBORw0…HTML src, CSS url(), anywhere an image address goes
Raw Base64iVBORw0…JSON payloads, API fields, databases that store the payload only

The prefix must match the real format: image/png for PNG, image/jpeg for JPG, image/webp for WebP, image/svg+xml for SVG. A wrong prefix can stop the image rendering. Never send a full data URL where a service asks for raw Base64 — strip everything through the first comma.

When Base64 embedding is a good idea (and when it is not)

Good: tiny icons, logos and sprites embedded in a single HTML/CSS file; images inside JSON or email templates; offline single-file pages; avoiding an extra HTTP request for one small asset.

Bad: large photos (33% bigger, blocks HTML parsing, no separate caching); images reused across many pages (a cached file wins); anything you update often (you must regenerate the string). Compress or resize first — every byte saved in the file saves ~1.34 characters in the output. Hellagape's Image Compressor and Image Resizer handle that step.

Tips and common mistakes

  • Shrink before you encode. Resize to the display size and compress; Base64 amplifies whatever you feed it.
  • Keep the payload on one line unless the receiving format explicitly allows line breaks; stray breaks break strict decoders.
  • Base64 is not encryption. Anyone can decode it back to the image. Never treat a Base64 string as a secret.
  • Check the first characters. PNG payloads start iVBORw0KGgo, JPEGs start /9j/. If yours differ, the file may not be the format you think.
  • Mind the page-weight budget. One embedded 30 KB logo (~40 KB of text) is fine; ten embedded photos will slow the page more than separate files would.

FAQ

How do I convert an image to Base64 for free? Open Hellagape's Image to Base64 tool, drop in the image, and copy the data URL. It runs in your browser with the Canvas API, so nothing is uploaded and there is no account or daily limit.

How much bigger is Base64 than the image file? About one-third bigger: 4 characters per 3 bytes. A 68-byte PNG becomes 92 characters; 1,024 bytes becomes 1,368 characters (verified maths above), plus a 22–23 character data-URL prefix when embedding.

What is the difference between Base64 and a data URL? Base64 is the encoded text alone. A data URL wraps it with data:[MIME type];base64, so browsers can use it as an image address in HTML and CSS. APIs usually want raw Base64 without the prefix.

Can I embed a Base64 image in CSS? Yes: background-image: url("data:image/png;base64,…");. This suits small decorative assets. Large backgrounds are better as separate, cacheable files.

Is it safe to convert images online? It is safe when conversion happens locally in your browser. Hellagape's page states images are decoded with the Canvas API and pixels never leave your device. Avoid upload-based converters for private images.

How do I convert Base64 back to an image? Use the reverse tool, Base64 to Image: paste the Base64 string (or full data URL) and download the decoded image file. Decoding restores the exact original bytes.

Why won't my Base64 image display? Check three things: the MIME prefix matches the real format, the payload has no line breaks or missing characters, and you did not send a data URL where raw Base64 was expected (or vice versa). Re-copy the full string first — truncation is the most common cause.

Should I Base64-encode all my website images? No. Embed only small, single-use assets. Larger or reused images should stay as files so browsers can cache them and load pages progressively. A practical ceiling is a few tens of kilobytes per embedded image.

Staged for hellagape.com — not yet published. Confirm live copy/download controls at publish time.

Try it now

Image to Base64

Encode an image as a Base64 data URL for CSS and HTML embedding.

Open the free tool