Home/Tools/Image Tools/Image to Base64

Image to Base64

Image Tools

Convert images to Base64 encoded strings.

⚡ Instant🔒 Private, in your browser🆓 Free, no sign-up👥 For everyone
Your data never leaves your browser. We do not store inputs.

Quick answer

How much bigger does an image get when it is converted to Base64?

About one third bigger: every 3 bytes of the image become 4 text characters. A 100 KB image becomes 136,536 characters. That is why Base64 suits tiny icons and API payloads but not photographs.

Base64 text length by image size
Image sizeBase64 charactersIncrease
1 KB1,36833.6%
10 KB13,65633.4%
100 KB136,53633.3%
1 MB1,398,10433.3%
Formula:
Base64 length = 4 × ceil(bytes ÷ 3). The text also needs a short prefix such as data:image/png;base64, when used as a data URI.
Assumptions:
Base64 is an encoding, not encryption, and an embedded image cannot be cached separately from the page that contains it.

These figures are computed with the same formulas as the Image to Base64 above. Change the inputs in the tool to see your own result.

What Image to Base64 does

Image to Base64 converts an image into a text string you can paste into HTML, CSS, JSON, Markdown or an API request, and converts Base64 back into an image. Choose from five ready-to-use outputs: a data URI, the raw Base64, an HTML img tag, a CSS background-image line or a Markdown image. The tool shows the size change and warns when an image is too large to inline sensibly. Everything runs in your browser and nothing is uploaded.

FV
Reviewed by the FreeToolsVerse team · Last updated · How we check our tools

Features and benefits

  • Five output formats and a decoder in one tool
  • Shows the size increase and warns about large images
  • Detects the image type of pasted Base64 without a prefix
  • Private: no uploads

How to use Image to Base64

  1. Click or drop an image (up to 10 MB)
  2. Choose the output: Data URI, Base64 only, HTML, CSS or Markdown
  3. Click the box to select the text or press Copy output
  4. To go the other way, open the "Base64 to image" tab and paste a string or data URI

Who should use it

Made for everyone. Typical uses:

  • Embedding a small icon or logo directly in HTML or CSS
  • Sending an image inside a JSON API request
  • Creating single-file HTML pages and demos
  • Decoding a Base64 string from a log, email or API response back into a picture

Example

A 4 KB PNG icon becomes about 5.5 KB of Base64 text, which you can paste as an img src or CSS url() so no separate file is loaded. Pasting a string that starts with iVBORw0KGgo shows a PNG preview and lets you download it as decoded-image.png.

Limitations and accuracy

Base64 makes data about a third larger and cannot be cached separately, so it suits small images only. Images over 10 MB are refused. Base64 is not encryption: anyone can decode it.

Accuracy: Images are processed with the browser's own image engine and tested with real photos and graphics. Check the result before you use it.

Expert Tip

Inline only small icons and logos, ideally under 10 KB. For photographs, a normal image file loads faster and can be cached.

Frequently asked questions

How do I convert an image to Base64?
Upload the image and copy the output. Choose Data URI for use in HTML src attributes and CSS url(), or Base64 only for APIs that add their own prefix.
What is a data URI?
A data URI puts the file inside the text itself, in the form data:image/png;base64, followed by the encoded data. Browsers display it like a normal image.
How do I convert Base64 back to an image?
Open the "Base64 to image" tab, paste the string with or without the data: prefix, and download the decoded image.
Is Base64 good for website images?
Only for tiny images. It increases the size by about a third and prevents separate caching, so use normal files for anything larger than about 10 to 20 KB.
Is my image uploaded?
No. Encoding and decoding happen in your browser.

Image to Base64: the complete guide

What Base64 encoding of an image is

Base64 is a way of writing binary data, such as an image file, using only ordinary text characters. Encoding a picture as Base64 lets you put it directly inside text: an HTML page, a CSS file, a JSON message, an email or a Markdown document, with no separate image file to load. In HTML it looks like a very long src attribute that begins with data:image/png;base64, followed by the encoded data. That whole string is called a data URI.

The tool encodes any image in your browser and shows the result in five ready-to-use forms: a data URI, the raw Base64 string, an HTML img tag, a CSS background-image line and a Markdown image. It also works in reverse: paste Base64 or a data URI and it shows the picture and lets you download it.

When inlining an image makes sense

Base64 images are useful in a few specific situations.

  • Very small images such as icons, loaders and one-pixel placeholders, where the cost of an extra web request is bigger than the image.
  • HTML emails, where linked images are often blocked but embedded ones may display (support varies between clients, so test).
  • Single-file HTML pages, reports and demos that must work without extra files.
  • API requests and JSON where a picture has to travel as text, for example to upload an avatar to a service that accepts Base64.
  • CSS with tiny background patterns.

When not to use it

Base64 makes data about a third bigger: three bytes become four characters. A 30 KB image becomes about 40 KB of text, and that text cannot be cached separately from the page that contains it, cannot be lazy-loaded and slows the page's first render. For photographs and anything over about 10 to 20 KB, a normal image file that the browser can cache and load in parallel is better. The tool warns you when a file is over 100 KB.

Compress and resize first if you must embed: the Image Compressor and Image Resizer can shrink a picture before it is encoded, and SVG to PNG helps if your logo is a vector. For vectors, embedding the SVG code directly is often smaller than any Base64 version.

Using the output

Choose the format that matches where the text will go. The data URI is what you paste into an img src or a CSS url(). The raw Base64 is what many APIs ask for, without the data: prefix. The HTML option gives a complete img tag with alt text taken from the file name, which you should replace with a real description for accessibility. The CSS option gives a background-image declaration. The Markdown option gives an image link for documents that support data URIs.

Click the text box to select all of it, or use the copy button. Very long strings are normal: a small icon can still be several thousand characters.

Decoding Base64 to an image

The second tab reverses the process. Paste a Base64 string, with or without the data:image prefix, and the tool checks it, detects the type from the first bytes if the prefix is missing, shows a preview and lets you download the file with the right extension. If the text is not valid Base64 image data, you get a clear message instead of a broken picture. Line breaks and spaces inside the pasted text are ignored, which helps with strings copied from emails or logs.

Privacy and limits

Encoding and decoding happen in your browser; the image and the text are never sent to a server. Files are limited to 10 MB because larger images produce text that is too big to copy. Base64 is not encryption: anyone can decode it, so do not treat it as a way to hide a picture. For more on image formats and file sizes, read JPG vs PNG vs WebP.

Learning resources

Explore more in Image Tools, read the guides and articles, or see how we test our tools.

Share This Tool