Home › Developer & Design › Image to Base64
Image to Base64 Encoder
Turn a small picture into text that can live inside your code.
How to encode an image
- Add an image smaller than 3 MB.
- Choose the output style.
- Press Encode, then Copy.
Output styles
- Data URL: the file type followed by the encoded data.
- Base64 only: the data without a prefix.
- CSS background: a ready background-image line.
- HTML img tag: an image element. Fill in the empty alt text to describe meaningful pictures.
What is Base64?
It writes binary data using letters, digits and a few symbols, so a file can travel inside text. Every 3 bytes become 4 characters, which makes the text about one third larger than the file.
When it makes sense
It can suit a tiny icon, an email template experiment or a single-file demo. Large photographs are usually better as separate files, which browsers can cache and which keep your code readable.
Example
A 6 KB icon becomes about 8 KB of text. Used in a stylesheet, it removes one file request but makes the stylesheet heavier for every visitor who downloads it.
It is not encryption
Anyone can decode Base64. Never use it to hide private information. Any metadata inside the original file remains in the encoded copy.
Before pasting into a project
Compare the size of the encoded text with the benefit. If the same image appears on many pages, a normal image file is usually easier to cache and replace. Some email programs block or ignore embedded data images, so send yourself a test. Keep the original file in your project so others can edit it later.
Frequently Asked Questions
Does encoding reduce quality?
No. The original file bytes are represented exactly.
Is my file uploaded?
No. Encoding happens on your device.