Convert an image to Base64
Switch to File to Base64 mode and choose an image. You get a full data URI, ready to paste into an img tag or a CSS background.
Runs in your browser. Your file never leaves this device.
Loading the tool…
When to embed an image as Base64
Base64 turns an image into plain text that can live inside HTML, CSS, JSON or an email template as a data URI. It is handy for tiny icons, email signatures and quick prototypes, where saving a separate file request matters.
Base64 text is about 33% larger than the original file, so it is not a good fit for large photos on a website.
Tips
- Keep Base64-embedded images under a few kilobytes.
- Copy the full data URI (starting with data:image/...) when pasting into an <img> src.
What this tool does
Base64 is a way of writing any data, text or a file, using only plain letters, numbers and a few symbols. Developers use it to put small images straight into HTML or CSS, to pass data through systems that only handle text, and to read values found in API responses and config files.
This tool has three modes. Text to Base64 encodes whatever you type, including Hindi or other scripts, using standard Base64. Base64 to text decodes a Base64 string back into readable text. File to Base64 reads any file and gives you a complete data URI, starting with data: and the file type, ready to paste into an img tag or a CSS background. Images get a preview.
Decoding only works when the result is text. It can't turn Base64 back into an image or other file yet. It also doesn't accept URL-safe Base64, the variant that uses - and _, or a string that still has its data: prefix.
Nothing you type or choose leaves your device, and once the page has loaded the tool needs no internet connection.
People use it for
- Embedding a small icon in HTML or CSS as a data URI
- Reading a Base64 value from an API response or a config file
- Encoding a username and password pair for a Basic Auth header while testing
- Checking what a Base64 string in an email header or log actually says
How to use it
Pick a mode
Choose Text to Base64, Base64 to text, or File to Base64.
Paste text or choose a file
Type or paste into the box, or drop a file in File mode. The result appears below with its length in characters.
Copy or save the result
Copy the output with one click. In decode mode you can also save the decoded text as a .txt file.
What it works with
| You give it | You get | Good to know |
|---|---|---|
| Text (any language) | Base64 | Standard Base64 with = padding |
| Base64 | Text | Must decode to readable text |
| Any file | Data URI (Base64) | Images also show a preview |