# Free Online Image to Base64 Converter

> Encode an image to a base64 data URI, or decode one back to a file. Runs entirely in this tab — the image is never uploaded. Free online.

Canonical: https://stayslocal.app/image/image-to-base64
Last updated: 2026-08-16

A data URI carries the whole image inline, as text, so it can sit inside a stylesheet, an HTML attribute or a JSON field with no separate file to host. Pick a direction — a file becomes a string, or a string becomes a file — and the conversion happens in this tab either way.

## Why the 4:3 expansion actually costs

Base64 maps three bytes to four printable characters, so the output is always exactly 4 × ceil(bytes ÷ 3) characters long — about 33% larger than the file it came from. That is expansion, not compression: a data URI never makes anything smaller, it only makes a binary file safe to put where only text is allowed. The shape is the data:[<mediatype>][;base64],<data> URI, defined in RFC 2397. It is worth remembering that base64 is an encoding, not encryption — the original bytes are fully recoverable by anyone who has the string. And there is a real ceiling on when this is worth doing: inlining an image into CSS or HTML trades away the browser's ability to cache that image separately from the page, which is a fair trade for a 2 KB icon and a mistake for a 2 MB photograph.

Fields:
- Output form: Raw base64, a full data: URI, a CSS background-image rule, or a ready-made <img> tag — pick whichever you're about to paste into.
- Alphabet: Output uses the standard +/ alphabet. Input accepts either the standard or the URL-safe -_ alphabet, so a string copied out of a URL or a JWT still decodes.
- Size: Shown before you copy anything: the source file's size and the exact character count it produces, not an estimate.
- Type detection: Decoding reads the image format from the bytes themselves, not from a data: prefix — so a mislabelled or relabelled data URI still decodes correctly, and you're told if the label was wrong.

## How to convert between an image and base64

1. Pick the image, or paste the string — Whichever direction you need — the same page does both.
2. Choose how you want it — Raw text, a data URI, a CSS rule, or an <img> tag.
3. Copy it, or download the file back — A decoded image downloads as the real format it actually is.

## Where a data URI earns its size

- Inlining a small icon into a stylesheet so it loads with no extra request.
- Embedding a logo directly in an HTML email, where linked images are often blocked.
- Building a fixture for a test or a seed script that needs a real image inline.
- Pasting an image into a JSON config or a YAML manifest that has no separate asset step.
- Recovering the actual image file from a data URI someone sent you.

## Questions

**Is base64 encryption?**

No. It is a reversible encoding with no key — anyone with the string can decode it back to the exact original bytes. Treat a base64 image the same way you would treat the file itself.

**Why is the string so much bigger than the file?**

Base64 spends four characters to represent every three bytes, which is a fixed 33% expansion — not a bug, just what encoding arbitrary bytes as printable text costs.

**Can I decode a data URI someone else sent me?**

Yes — paste it into the Base64 → Image side, in full or just the payload after the comma. It decodes the same way regardless of which tool produced it.

**Is my image uploaded to do this?**

No. The file is read from disk and encoded in this tab; a pasted string is decoded the same way. Open the network tab while using this page and nothing appears in it.

**Why does a large image make the page slow?**

The base64 string is held in memory and rendered into a text box, and a multi-megabyte string is a lot for a textarea to lay out. Use the .txt download instead of copying for anything past a megabyte or so, and compress the source image first if you don't need it at full size.

## Related

- [Base64 Encoder & Decoder](https://stayslocal.app/dev/base64-encoder-decoder): Encode and decode base64 text
- [Image Compressor](https://stayslocal.app/image/image-compressor): Shrink a photo without visible loss
- [Image Tools](https://stayslocal.app/image): every tool in this family
