FlipMyFormat

Image to Base64 Converter

Turn pictures into Base64 text as a data URL, HTML img tag, CSS, Markdown or JSON, make them shorter first, or decode Base64 back into a picture. Free, nothing uploaded.

Select images

or drop them here · or paste a screenshot with Ctrl+V

Encoded in your browser. Your pictures are not uploaded.

Output as

data:image/png;base64,… works directly in src="", CSS url() and most apps.

Make it shorter first

Base64 is about 33% bigger than the file. Smaller pictures make shorter code and faster pages.

Good to know

Data URLs suit icons, logos and small pictures (under ~10 KB). Big photos are better as normal files.

People also use

How to turn a picture into Base64 in three steps

Add one or more pictures to the box above, pick how you want the text, and copy it. Each picture is turned into Base64 the moment you add it, so there is no button to press and nothing to wait for. You can get a data URL, the Base64 text only, a ready HTML img tag, a CSS background rule, a Markdown image link or a small JSON object.

Everything happens in your browser. Your pictures are read and encoded on your own device and are not uploaded anywhere. You can add up to 100 pictures at once, each up to 20 MB, in PNG, JPG, GIF, SVG, WebP, ICO, BMP or AVIF, and you can paste a screenshot straight from the clipboard with Ctrl+V.

The switch at the top of the tool turns it around. Choose Base64 → Image, paste Base64 text or a data URL, and the tool turns it back into a picture that you can see and download.

  1. 1

    Add your pictures

    Click Select images, drop files on the box or paste a screenshot with Ctrl+V. PNG, JPG, GIF, SVG, WebP, ICO, BMP and AVIF work, up to 100 pictures of 20 MB each.

  2. 2

    Choose the output

    Pick Data URL, Base64 only, HTML img, CSS background, Markdown or JSON. If the text is too long, use Make it shorter first to resize the picture or save it as WebP or JPG.

  3. 3

    Copy or download

    Press Copy next to a picture, or download the text as a file. With several pictures you get one ZIP with a text file for each picture.

The defaults suit most jobs: a data URL of the picture exactly as it is, with nothing resized or recompressed. The sizes before and after and the number of characters are shown next to every picture, so you can see at once whether the text is short enough for where you want to use it.

What is Base64?

Base64 is a way of writing any file, including a picture, with only 64 safe characters: the capital letters A to Z, the small letters a to z, the digits 0 to 9, and the two signs plus and slash. The equals sign is used at the end as padding. Because these characters pass through almost every system untouched, Base64 lets you put a picture into places that only accept text, such as an HTML file, a stylesheet, a JSON field, an email template or a database column.

The encoding works in groups. Every 3 bytes of the file, 24 bits, are split into 4 pieces of 6 bits, and each piece becomes one of the 64 characters. That is why Base64 text is always about four thirds of the file size, roughly 33% bigger. If the file length is not a multiple of 3, one or two equals signs are added at the end so the text length is a multiple of 4.

Base64 is not encryption and not compression. Anyone can turn the text back into the picture, and the text never makes the picture smaller. It is simply a different way of writing the same bytes, so that they can travel inside text.

Below is a complete picture written as a data URL: a PNG of a single pixel. The part before the comma says what kind of file it is, the long part after the comma is the Base64 text of the PNG file.

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==

Image to Base64 data URL: how it is built

A data URL, also called a data URI, is a web address that carries the file itself instead of pointing to a file on a server. Browsers accept it anywhere a normal image address is allowed: in the src of an img tag, in a CSS url(), in JavaScript, and in many apps that take a link to a picture. This is what you get with the Data URL output.

When people ask for an image to Base64 data URL, they usually want to place a small picture into a page or a file without a separate download. The tool writes the correct type for each picture at the start, for example data:image/png;base64, for PNG, data:image/jpeg;base64, for JPG, data:image/webp;base64, for WebP and data:image/svg+xml;base64, for SVG. If the type is wrong, some browsers refuse to show the picture, so the tool always takes it from the file itself.

A data URL has no file name and no separate cache entry. It is part of the text around it, so it is loaded when that text is loaded and cached only together with it. That is the main reason data URLs are great for tiny pictures and a poor choice for large ones, as explained further down.

PartNameMeaning
data:The schemeTells the browser that the file follows in the address itself
image/pngThe media typeWhat kind of file it is; must match the real bytes
;base64The encodingSays that the data after the comma is Base64
,The separatorEverything after the comma is the file
iVBORw0KGgo…The dataThe Base64 text of the file; PNG files always start with iVBORw0KGgo

How much bigger Base64 makes a file

Base64 text is always about 33% bigger than the file it comes from, because every 3 bytes become 4 characters. A data URL adds a short header, around 22 characters, and an HTML tag or a CSS rule a few more. Line breaks, if a system adds them every 76 characters, add a little more.

Web servers usually send pages and stylesheets gzip or Brotli compressed, and that wins back part of the overhead on the wire, often bringing it down to somewhere between 2% and 10% over the original file. On disk, in a database or in a JSON body that is not compressed, the full 33% applies.

File sizeBase64 charactersText sizeInline it?
1 KB1,368About 1.4 KBA small icon: a good fit
5 KB6,828About 6.7 KBA logo or simple graphic: fine
10 KB13,656About 13.4 KBThe usual upper limit for inlining
50 KB68,268About 67 KBBetter as a normal file in most cases
100 KB136,536About 133 KBA photo: keep it as a file
1 MB1,398,104About 1.33 MBToo long for HTML, CSS or email
5 MB6,990,508About 6.7 MBOnly for APIs and storage that need text

Characters are for Base64 only; a data URL adds about 22 more. One KB is 1,024 bytes here. The tool shows the exact number of characters for each picture and for all pictures together.

When Base64 pictures are a good idea

Small icons and logos

Pictures of a few kilobytes save a request to the server and appear together with the page, without flicker.

Single-file HTML

Reports, offline pages, demos and exported documents that must work as one file without a folder of pictures.

CSS sprites and UI details

Arrows, check marks, patterns and small backgrounds inside a stylesheet that is cached anyway.

APIs and JSON

Many APIs, including image and AI services, expect pictures as a Base64 field in a JSON body.

Databases and config files

Storing a small avatar, a signature or a thumbnail in a text column or a settings file.

Tests and examples

Sample pictures in unit tests, code examples and bug reports that should not depend on outside files.

When to keep a normal image file

Large photos

A 2 MB photo becomes about 2.7 million characters. The page or file grows by that much and becomes slow to load and to edit.

Pictures used on many pages

A normal picture file is downloaded once and cached. Inline Base64 is downloaded again with every page that contains it.

Pictures that change often

Every change to the picture changes the HTML or CSS around it, so the whole file has to be downloaded again.

Content images that should be found

Search engines index normal image files with their names and addresses; inline pictures are rarely shown in image search.

Most emails

Many email apps block or strip data-URL images. Attachments or linked images are more reliable.

Responsive images

srcset with several sizes works best with real files; repeating several large data URLs makes the page very heavy.

Six output formats and where each one goes

Data URL

The full address that starts with data:image/…;base64, and works in src, CSS url(), JavaScript and many apps. The most common choice.

Base64 only

Just the encoded text, without the data: header. For APIs, JSON fields, databases and programs that add the type themselves.

HTML img

A ready img tag with the picture inside, the alt text you type (or the file name) and the width and height of the picture.

CSS background

A background-image rule with the data URL inside url(), ready to paste into a stylesheet or a style attribute.

Markdown

An image link in Markdown with the alt text in square brackets and the data URL in round brackets.

JSON

A small object with the file name, the type, the width and height and the Base64 data, ready for an API or a test file.

Data URL

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==

Base64 only

iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==

HTML img

<img src="data:image/png;base64,iVBORw0KGgo…" alt="Company logo" width="120" height="40">

CSS background

background-image: url("data:image/png;base64,iVBORw0KGgo…");

Markdown

![Company logo](data:image/png;base64,iVBORw0KGgo…)

JSON

{"name":"logo.png","type":"image/png","width":120,"height":40,"data":"iVBORw0KGgo…"}

The examples are shortened with … so they fit on the page. The text you copy from the tool is always complete.

Image to Base64 for HTML: the img tag

For image to Base64 for HTML, choose HTML img. The tool writes a complete img tag: the data URL goes into src, the alt text you type goes into alt, and the width and height of the picture are added so the browser can reserve the space before the picture is drawn. That stops the page from jumping while it loads. If you leave the alt field empty, the file name without its extension is used, but a short description of the picture is better for screen readers and for search engines.

Paste the tag wherever a normal img tag would go. It works in plain HTML files, in templates of most frameworks, in CMS fields that accept HTML and in single-file reports. Some content systems remove data URLs for safety; if the picture disappears after saving, the system is filtering it and a normal image file is needed.

Keep inline pictures small. A rule of thumb used by many developers is to inline only pictures under about 10 KB, such as icons, logos and simple shapes. For anything larger, a normal file with loading set to lazy is usually faster, because the browser can cache it and load it in parallel. After pasting many tags, HTML Minifier can remove the extra spaces from the rest of the file.

Base64 pictures in CSS

Choose CSS background to get a rule such as background-image with the data URL inside url(). Paste it into a class in your stylesheet or into a style attribute. This is a common way to ship small icons, patterns, arrows, check marks and loading spinners together with the CSS, so they appear the moment the styles apply.

Because the stylesheet is usually cached, the inline pictures are cached with it, which makes CSS a better home for repeated small pictures than HTML. The downside is that the browser cannot start drawing the page until the stylesheet has arrived, so a stylesheet full of large data URLs delays everything. Keep each one small and add only pictures that are really used on most pages.

SVG icons can also be placed in CSS without Base64, as URL-encoded text, which is often a little shorter. URL Encode helps with that. For PNG, JPG, WebP and GIF pictures Base64 is the normal way.

Image to Base64 string for APIs, JSON and databases

Many APIs ask for a picture as an image to Base64 string: the encoded text placed in a JSON field, often called image, data, file or content. Some want the full data URL, others want only the Base64 part. Read the documentation of the API: if it asks for a separate mime type or media type field, it almost always wants Base64 only.

Choose Base64 only to copy just the encoded text, or JSON to get a small object with the name, the type, the width, the height and the data, which you can adapt to the field names the API expects. JSON Formatter makes long JSON easier to read and check before sending it.

In code, the same thing can be done with built-in functions. In a browser, FileReader with readAsDataURL gives a data URL. In Node.js, reading the file into a Buffer and calling toString with base64 gives the text. In Python, base64.b64encode on the bytes of the file does the same. The tool is useful when you need the result quickly, want to check what a program produced, or want to make the picture smaller before encoding it.

Check the size limits. Many APIs limit the body of a request to a few megabytes, and because Base64 is a third larger than the file, a 4 MB picture can already be too much. Make it shorter first with a smaller longest side or WebP, which often brings photos down to a fraction of their size.

FormExampleUsed by
Full data URLdata:image/jpeg;base64,/9j/4AAQ…Browsers, some AI and image APIs, front-end code
Base64 only/9j/4AAQSkZJRg…Most REST APIs, databases, mobile apps
Base64 with a type field"mime": "image/png", "data": "iVBORw0…"APIs that ask for the media type separately
URL-safe Base64Uses - and _ instead of + and /Tokens, URLs and some cloud APIs

Encoding pictures in your own code

If you need to encode pictures again and again, for example in a build step or on a server, it is worth doing it in code. All common languages have Base64 built in, so no extra package is needed. The short examples below show the usual way in a browser, in Node.js, in Python and on the command line.

Whichever way you choose, remember two things. First, add the right media type when you build a data URL yourself; a JPG must say image/jpeg, not image/jpg. Second, Base64 text from the command line on Linux is broken into lines of 76 characters by default, which must be removed for a data URL, which is why the example uses -w 0. On a Mac, the base64 command writes one line by default.

Browser JavaScript

const reader = new FileReader();
reader.onload = () => console.log(reader.result); // data:image/png;base64,…
reader.readAsDataURL(file);

Node.js

const fs = require("fs");
const b64 = fs.readFileSync("logo.png").toString("base64");
const dataUrl = "data:image/png;base64," + b64;

Python

import base64
with open("logo.png", "rb") as f:
    b64 = base64.b64encode(f.read()).decode("ascii")
data_url = "data:image/png;base64," + b64

Command line (Linux)

base64 -w 0 logo.png > logo.txt

When a site blocks data URLs

Some sites use a Content Security Policy, a header that tells the browser where pictures may come from. If the img-src rule does not list data:, the browser refuses every data URL picture on the page, even a correct one, and writes a message about the policy in the console of the developer tools.

If your data URL pictures work in a plain test file but not on your site, check the policy first. Adding data: to img-src allows them. Some security teams prefer not to allow data URLs at all; in that case use normal image files, which are just as fast for anything larger than a tiny icon.

Rich text editors, comment fields and forum software often remove data URLs from what users paste, for the same safety reasons, and some image proxies replace them with an empty picture. That is not a fault in the Base64 text; the place simply does not allow it.

Base64 in databases, storage and config files

Storing pictures as Base64 in a database is easy, but costs space: every picture takes about a third more room than as binary data, and large text columns slow down queries that read whole rows. For avatars, signatures and thumbnails of a few kilobytes this is usually fine. For photos, a binary column or file storage with only the address in the database is the better design.

The same goes for local storage in the browser, which is limited to a few megabytes on most sites. A handful of photos as data URLs can fill it up, and the browser then refuses to save anything more. Keep stored pictures small, or use IndexedDB, which can hold binary data directly.

Configuration files, translation files and JSON fixtures in a code repository become hard to read and to compare when they contain long Base64 lines. A separate picture file next to them is usually easier to maintain, and version control shows changes to it more clearly.

Image to Base64 for email: test before sending

Image to Base64 for email sounds like a neat trick: put the logo inside the message, and it shows even when remote pictures are blocked. In practice it is unreliable. Many email apps block or strip data-URL images; test before sending. Gmail in particular removes them in many cases, some Outlook versions do not show them, and spam filters can treat large inline Base64 blocks as suspicious.

The more reliable ways are a normal linked image on a web server, or an attachment referenced inside the message with a content ID, which is what most email programs and sending services do when you insert a picture. If you still want to try a data URL, keep the picture tiny, set the width and height, add a clear alt text, and send test messages to every email app your readers use before the real mailing.

Base64 does matter in email behind the scenes: attachments are encoded as Base64 inside the message source. That is handled by the email program, not by you, and it is one reason why an attachment makes a message about a third bigger than the file.

Image to Base64 for Markdown and README files

Choose Markdown to get an image link with the data URL inside the round brackets and the alt text inside the square brackets. Image to Base64 for Markdown is handy for notes, README files in private tools, documentation generators and static site builders that render Markdown to HTML, because the picture travels with the text file.

Support depends on the place that shows the Markdown. Many editors and static site generators render data URLs fine. GitHub and some other hosted sites may not render data URLs in their Markdown and show a broken picture or the raw text instead, and very long lines can make the file hard to edit. For such sites, commit the picture as a normal file and link to it.

If you use data URLs in Markdown, keep the pictures very small, give them a real alt text, and preview the page on the site where it will be read before you rely on it.

PNG to Base64: logos, icons and screenshots

PNG to Base64 is the most common job on this page, because logos, icons, screenshots and UI graphics are usually PNG files with sharp edges and transparency. Add the PNG, and the data URL starts with data:image/png;base64, and keeps the transparency exactly as it was.

PNG files of photos can be large. If a PNG is a photo or a screenshot with many colours, Make it shorter first with WebP often makes the text a fraction of the length while keeping transparency. JPG makes it shorter still but fills transparent areas with white. To keep a PNG as PNG but smaller, choose a smaller longest side; for pixel-perfect icons, leave the setting on Keep the file.

Before encoding many PNG icons, check whether they really need the full size. An icon shown at 24 pixels does not need to be stored at 512 pixels; choosing 64 px as the longest side is enough for sharp display on high-density screens and can cut the text to a tenth of its length.

SVG pictures as Base64

SVG pictures are text already, so they are encoded exactly as they are and are never resized or recompressed by the tool. The data URL starts with data:image/svg+xml;base64, and works in img tags and CSS like any other picture.

For SVG there is an alternative to Base64: URL-encoded SVG text inside the data URL, which is often a little shorter and stays readable. Both work in browsers. Base64 is safer when the SVG contains quotes, hash signs or line breaks that would otherwise need escaping. If a program cannot show SVG at all, SVG to PNG turns it into a PNG that you can then encode.

A favicon as a data URL

A favicon can also be a data URL. Put it in the href of the link tag with rel icon, and the browser shows it without a separate request. This is handy for single-file HTML pages, internal tools and pages opened from a local file, where no favicon.ico file exists.

Use a small PNG or SVG of 32 or 64 pixels; an ICO file can be encoded too and is kept exactly as it is. Larger favicons only make the page heavier, because the browser shows them at 16 to 32 pixels in the tab anyway.

Image to Base64 from clipboard: paste a screenshot

Image to Base64 from clipboard saves the step of saving a file first. Take a screenshot, or copy a picture in an image editor or a browser, then click anywhere on this page outside a text box and press Ctrl+V, or Cmd+V on a Mac. The picture is added to the list and encoded at once, just like a file.

Screenshots are usually PNG files, often large ones on high-resolution screens. If you only need a small preview, choose a longest side such as 800 or 1200 px and WebP under Make it shorter first before pasting, so the text stays manageable.

Pasting works in current versions of Chrome, Edge, Firefox and Safari. Some browsers only paste pictures that were copied as image data, not files copied in a file manager; if nothing happens, save the picture and add it with Select images instead.

Make it shorter first: smaller pictures, shorter text

Because Base64 makes the text about a third longer than the file, the best way to get shorter text is a smaller file. Make it shorter first does that before encoding. Keep the file leaves the picture untouched. WebP saves it as WebP, usually the smallest choice for photos and screenshots and it keeps transparency. JPG is small and supported everywhere, but transparent areas become white. PNG is lossless and best for flat graphics.

Longest side scales the picture so its bigger side is at most 2000, 1200, 800, 512, 256, 128 or 64 pixels; smaller pictures are left as they are. For WebP and JPG the quality slider runs from 40 to 100. The default of 85 looks the same as the original for most pictures; lower values give shorter text with some loss of detail.

When you change these settings, the pictures already in the list are encoded again with the new settings, so you can try several and watch the character count change. SVG and GIF pictures are never resized or converted, so animation and vector shapes are kept. For finer control, Compress Image and Resize Image offer more choices; PNG to WebP turns a whole folder of PNG files into WebP files first.

SettingText lengthFileGood for
Keep the fileUnchangedExact copy, any formatIcons, logos, pixel-perfect graphics
WebPOften much shorterSmall, keeps transparencyPhotos, screenshots, banners
JPGOften much shorterSmall, no transparencyPhotos for APIs and older systems
PNGSimilar or shorterLossless, keeps transparencyFlat graphics that must stay sharp
Longest side 64 to 256 pxMuch shorterFewer pixelsIcons, avatars, thumbnails

Does Base64 change the picture quality?

Encoding never changes the picture. Base64 is a lossless way of writing bytes, so when the text is decoded you get exactly the same file back, bit for bit. A PNG stays a PNG with every pixel, a JPG stays the same JPG, and an animated GIF keeps all its frames.

The picture only changes when you ask for it under Make it shorter first. Resizing reduces the number of pixels, and WebP or JPG at a quality below 100 removes some fine detail to make the file smaller. At the default quality of 85 most people cannot see a difference at normal viewing size, but if you need an exact copy, leave the setting on Keep the file with Original as the longest side.

One small detail: when a picture is redrawn for resizing or a format change, information stored next to the pixels, such as camera data, GPS location and colour profiles, is not carried over. That is often welcome, because a data URL in a public page or an API request should not reveal where a photo was taken. With Keep the file and Original size, the file is encoded exactly as it is, including such data.

Many pictures at once: copy, download and ZIP

Add many pictures at once, up to 100 per batch, by selecting them together, dropping a group of files or adding more with Add more. Each picture gets its own row with a small preview, the type, the width and height, the size before and after and the number of characters of the output you picked.

Copy works per picture. To take everything at once, Download all saves one ZIP with a text file for each picture, named after the picture with -base64 and the extension of the output, such as logo-base64.css or photo-base64.json. If two pictures have the same name, a number is added so nothing is overwritten. With a single picture, the button saves the text file directly without a ZIP.

The total line above the list adds up all the pictures, which helps when you have a budget for the size of a stylesheet or an email template. Remove a picture with the small cross, or clear the whole list and start again.

Performance: keep pages fast

Inline pictures save a request to the server, which mattered a lot in the days of HTTP/1.1. With HTTP/2 and HTTP/3, many small files load in parallel over one connection, so that advantage is smaller today, while the costs stay: a third more bytes, no separate caching, and slower parsing of very long HTML or CSS.

A good rule is to inline only what is tiny, needed immediately and used in one place: a logo in the header of a single-file report, a few UI icons, a placeholder shown while a larger picture loads. Keep larger pictures as normal files with width, height and lazy loading, in a modern format such as WebP.

Measure rather than guess. Open the network panel of your browser's developer tools, check the size of the HTML and CSS before and after inlining, and look at how quickly the first content appears. If the page got slower, move the larger pictures back to files.

Alt text and accessibility

A picture inside the code is still a picture for your readers, so it needs the same care as any other. Give every HTML and Markdown image a short alt text that says what the picture shows or does, such as the company name for a logo or Search for a magnifying glass icon. Pictures that are only decoration can have an empty alt text, so screen readers skip them.

Background pictures in CSS are not seen by screen readers at all. If a CSS background carries meaning, such as an icon on a button without a label, add a text label or an aria-label to the element. Width and height on img tags help everyone, because the page does not jump when the picture appears.

Supported formats and their types

FormatMIME typeNotes
PNGimage/pngKeeps transparency; the most common format for icons and screenshots
JPG / JPEGimage/jpegPhotos; no transparency
GIFimage/gifEncoded as it is, so animation is kept
SVGimage/svg+xmlEncoded as it is; vector shapes stay sharp at every size
WebPimage/webpSmall files with transparency; supported by all current browsers
ICOimage/x-iconFavicons; encoded as they are
BMPimage/bmpUncompressed and large; WebP or PNG under Make it shorter first helps a lot
AVIFimage/avifVery small files; supported by current browsers

How the image to Base64 encoder works

The image to Base64 encoder on this page runs in JavaScript in your browser. When you add a picture, the browser reads the file. If you chose to make it shorter, the picture is drawn onto a canvas at the new size and saved as WebP, JPG or PNG with the quality you set. Then the file is read with the browser's own FileReader, which returns the data URL.

The tool checks the type at the start of the data URL and writes the correct one for the file it encoded, then builds the output you picked: it cuts off the header for Base64 only, wraps it in an img tag with alt, width and height for HTML, in url() for CSS, in square and round brackets for Markdown, or into an object for JSON. Quotes and angle brackets in the alt text are escaped so the HTML stays valid.

Pictures that the browser cannot draw, such as many ICO files, are encoded exactly as they are, without resizing. The original file is kept in memory while the page is open, so changing the settings encodes it again from the original and never from an already shrunk copy.

A free image to Base64 converter with no sign-up

This image to Base64 converter is free to use, with no sign-up, no watermark and no limit on how often you use it. Each batch can hold up to 100 pictures of 20 MB each, and you can clear the list and start again as often as you like.

Because the work is done by your own device, there is no queue and no upload time. Small pictures are encoded instantly; even a batch of large photos usually takes only a few seconds on a computer. Your choice of output and settings is remembered in your browser for the next visit.

Image to Base64 decode: from text back to a picture

Image to Base64 decode means the reverse direction: you have the text and want the picture back. Switch the tool to Base64 → Image, paste the text and press Decode to image. You see a preview, the file type, the width and height and the size, and you can download the picture as a file.

The decoder is forgiving. It accepts a full data URL or the Base64 text alone, line breaks and spaces anywhere, quotes or brackets around the text copied from code, and URL-safe Base64 that uses - and _ instead of + and /. Missing equals signs at the end are added automatically.

The file type is detected from the decoded bytes, not only from the header. PNG, JPG, GIF, WebP, AVIF, BMP, ICO and SVG are recognised from their first bytes, so a data URL with a wrong type still gives the right file with the right extension. If the text turns out to be a PDF, it is offered as a PDF. For a page that only decodes, see Base64 to Image; for Base64 of any text, Base64 Encode and Decode.

What the decoder accepts

  • A full data URL such as data:image/png;base64,iVBORw0KGgo…
  • Base64 text without any header
  • Text with line breaks every 76 characters, as in emails and PEM-style files
  • Text wrapped in double quotes, single quotes or backticks from source code
  • URL-safe Base64 with - and _ instead of + and /
  • Text with the equals-sign padding missing at the end

Troubleshooting: broken images, wrong types, cut-off text

The picture shows as broken

Usually the text is incomplete or the header is wrong. Copy the whole text again with the Copy button, and check that the data URL starts with data:image/ and contains ;base64, before the comma.

Wrong MIME type

A JPG labelled image/png may not show in some programs. Decode the text here: the type is detected from the bytes, and you can encode the downloaded file again to get the correct header.

The string is truncated

Long text is often cut off by editors, chat apps, spreadsheets or database columns with a size limit. Base64 that is cut off usually ends without = or ==; download the text as a file instead of pasting it.

Not valid Base64

Text with other characters, such as spaces inside words, HTML entities or escaped slashes, cannot be decoded. Remove the extra characters or copy it from the original source.

Nothing happens on Ctrl+V

Click on the page outside a text box first, and copy the picture itself, not the file. Or save it and use Select images.

The text is far too long

Use Make it shorter first: WebP and a longest side of 800 px or less make most pictures many times shorter.

The image does not show in an email

Many email apps block or strip data-URL images. Use a linked image or an attachment and test before sending.

The image does not show on GitHub

Some Markdown sites do not render data URLs. Commit the picture as a file and link to it.

Examples: four common jobs

A logo in a single-file report

Add the 6 KB PNG logo, choose HTML img, type the company name as alt text and paste the tag into the report template.

A photo for an image API

Add the photo, choose WebP with a longest side of 1200 px under Make it shorter first, choose Base64 only and copy it into the JSON field.

Icons in a stylesheet

Add ten small PNG icons, choose 64 px as the longest side and CSS background, then download all as one ZIP of .css files.

A broken data URL from a bug report

Switch to Base64 → Image, paste the text, and see at once whether it is complete and which file type it really is.

Tips for good Base64 pictures

  • Inline only small pictures, ideally under about 10 KB; keep photos as normal files.
  • Make pictures the size they are shown at before encoding, not larger.
  • Use WebP for photos and screenshots, PNG or SVG for sharp graphics.
  • Always add a real alt text to HTML and Markdown images.
  • Copy with the button or download the text; selecting long text by hand often misses a part.
  • Test data URLs in the place they will be used: the browser, the email app or the Markdown site.

Base64 terms explained

Base64

A way of writing any file with 64 safe text characters; the text is about a third larger than the file.

Data URL / data URI

An address that contains the file itself, such as data:image/png;base64, followed by the data.

MIME type

The label that says what kind of file it is, such as image/png or image/jpeg.

Padding

One or two equals signs at the end that make the length a multiple of 4.

URL-safe Base64

A variant that uses - and _ instead of + and / so the text can be used in addresses.

Inline image

A picture placed inside HTML or CSS as text instead of being loaded from a separate file.

Is it safe? Your pictures are not uploaded

Your pictures are not uploaded. Reading the file, making it smaller, encoding it and decoding text all happen in your browser, on your own device. No copy of your pictures or of the Base64 text reaches our servers.

That matters, because Base64 strings often end up in places with private data: screenshots with account details, signatures, ID scans for a form, pictures for a private API. When you close the page, the pictures and the text are gone from it. Only your choice of settings is remembered in your browser.

What to do next

To turn Base64 back into files on a page made only for that, use Base64 to Image. For text, JSON or other data that is not a picture, Base64 Encode and Decode converts both ways.

To make pictures smaller before encoding, Compress Image and Resize Image give more control, and PNG to WebP converts PNG files to WebP in one go. JSON Formatter and HTML Minifier help with the code around your Base64 text. All our picture tools are listed under Image Tools.

Frequently asked questions

How do I convert a picture into Base64?

Add the picture to the box on this page or paste it with Ctrl+V. It is encoded at once; choose the output you need and press Copy or download it.

Is this image to Base64 converter free?

Yes. There is no sign-up, no watermark and no limit on how often you use it, with up to 100 pictures of 20 MB each per batch.

Are my pictures uploaded?

No. Everything is done in your browser on your own device. Neither the pictures nor the Base64 text are sent to a server.

What is an image to Base64 data URL?

It is an address that contains the picture itself, such as data:image/png;base64, followed by the encoded text. Browsers accept it in img tags, CSS and JavaScript.

How do I convert PNG to Base64?

Add the PNG file and choose an output. PNG to Base64 keeps transparency, and the data URL starts with data:image/png;base64.

How do I use an image to Base64 for HTML?

Choose HTML img. You get an img tag with the data URL in src, your alt text and the width and height, ready to paste into a page.

What is an image to Base64 string?

It is the encoded text of the picture without the data: header. Choose Base64 only for APIs, JSON fields and databases.

Does image to Base64 for email work?

Often not. Many email apps block or strip data-URL images, Gmail in many cases. Test before sending; linked images or attachments are more reliable.

Can I use image to Base64 for Markdown?

Yes, choose Markdown. Many editors show it, but sites such as GitHub may not render data URLs, so check the place where it will be read.

How does the image to Base64 encoder work?

Your browser reads the file, optionally makes it smaller on a canvas, and encodes the bytes with its own FileReader. Nothing leaves your device.

Can I paste an image to Base64 from clipboard?

Yes. Copy a picture or take a screenshot, click on the page and press Ctrl+V or Cmd+V. It is added and encoded like a file.

How do I do an image to Base64 decode?

Switch to Base64 → Image, paste the text or data URL and press Decode to image. You see a preview and can download the file.

Why is the Base64 text bigger than the file?

Every 3 bytes become 4 characters, so the text is about 33% larger. Compression on the web server wins part of it back.

How can I make the Base64 shorter?

Use Make it shorter first: choose WebP or JPG and a smaller longest side. A smaller file always gives shorter text.

What is the largest picture I should inline?

As a rule of thumb, about 10 KB. Larger pictures are usually faster as normal files that the browser can cache.

Which formats can I encode?

PNG, JPG, GIF, SVG, WebP, ICO, BMP and AVIF. GIF and SVG are encoded as they are, so animation and vector shapes are kept.

Is Base64 encryption?

No. Anyone can decode it back into the picture. It only changes how the bytes are written, not who can read them.

Why does my data URL show a broken picture?

Usually the text was cut off or the type in the header is wrong. Copy it again with the Copy button or decode it here to check.

Does decoding accept URL-safe Base64 and line breaks?

Yes. Line breaks, spaces, quotes, URL-safe characters and missing padding are all accepted, and the file type is found from the bytes.

Can I get the output as a file?

Yes. One picture downloads as .txt, .html, .css, .md or .json depending on the output; several pictures download as one ZIP.

Does it work on a phone?

Yes. It runs in the browser on iPhone, iPad and Android with nothing to install; pasting from the clipboard depends on the browser.

Turn your pictures into Base64 now

Data URL, HTML, CSS, Markdown or JSON. Free and private.

Add your pictures

Last updated October 2026 · Written and maintained by the FlipMyFormat team