Image to Base64

Turn pictures into Base64, data URLs and ready HTML or CSS in your browser. Free, many at once, nothing uploaded.

Your pictures are turned into text in your browser. They are not uploaded.

PNG, JPG, GIF, WebP, AVIF, SVG, BMP and ICO files, and TIFF, HEIC and JPEG XL too. One picture or many at once. Drop them here, or paste a picture or the code of an SVG with Ctrl+V (⌘V on a Mac).

or

The text you need

An SVG is text already. With only its awkward characters spelled out it is shorter than its Base64 for most SVG files, and a browser reads the same picture from it.

These choices are remembered on this device and nowhere else. Your pictures never are.

Good to know

Base64 writes every 3 bytes of a file as 4 characters, chosen from 64 that pass wherever text does. So the text is a third longer than the file, and it holds the file itself: decoded, it gives the same bytes. Nothing about the picture changes and nothing is left out. An animation still moves, and what a camera wrote into a photo is still there.

A data URL is that text with the kind of picture in front, as in data:image/png;base64,… It goes wherever the address of a picture goes: into the src of an image, or into url("…") in a style sheet. The picture is then part of that page or style sheet and needs no request of its own. It also travels with that file every time the file is sent: a browser cannot keep it apart, as it keeps a picture that is a file of its own.

Web servers send text packed. The Base64 of a picture that is packed already, as a PNG, a JPG or a WebP is, then shrinks back to about the size of the file. The Base64 of an SVG does not: it packs far worse than the SVG itself, while the same SVG written as text packs nearly as well. The page works both sizes out for each picture.

The page tells what kind of picture a file is by how the file begins, never by its name.

Rate this tool

How useful was this tool?

Image to Base64

To convert an image to Base64, click Choose pictures to turn into Base64 and pick one or more files, drop them on the box, or paste a picture. As the page says: “PNG, JPG, GIF, WebP, AVIF, SVG, BMP and ICO files, and TIFF, HEIC and JPEG XL too. One picture or many at once. Drop them here, or paste a picture or the code of an SVG with Ctrl+V (⌘V on a Mac).”

Nothing else needs a click: each picture gets its own card at once, with its text in a box. Click Copy and the page answers Copied., or click Save as a file and it answers Saved. Under The text you need, Write each picture as decides what that text is: a data URL, bare Base64, or a ready line of HTML, CSS, Markdown or JSON.

Everything happens in your browser. The page says: “Your pictures are turned into text in your browser. They are not uploaded.” In every test run, the page sent nothing anywhere while it worked.

Which pictures it takes: PNG, JPG, SVG and eight more kinds

The page takes eleven kinds of picture: PNG, JPG, GIF, WebP, AVIF, SVG, BMP, ICO, TIFF, HEIC (and HEIF) and JPEG XL. It tells them apart by the file’s content. As its Good to know box puts it: “The page tells what kind of picture a file is by how the file begins, never by its name.”

That matters because the kind goes into the text. A data URL starts with it: image/png, image/jpeg, image/gif, image/webp, image/avif, image/svg+xml, image/bmp, image/x-icon, image/tiff, image/heic (image/heif) or image/jxl. A file whose name says one kind while it holds another gets the right label, and a note:

The name of the file ends in .png, but the file is a JPG picture. The text says image/jpeg, which is what the file is.

A file with no ending at all is read the same way.

A packed SVG (.svgz) is unpacked first, because a data URL can’t say that its content is packed. Its card says so, for example: “This was a packed SVG (.svgz) of 351 bytes. A data URL cannot say that its content is packed, so the page unpacked it: the text holds the SVG inside.”

A file that isn’t a picture gets a card with its name and the reason, and the other files are still done:

  • “This file is not a picture: it does not begin the way a PNG, JPG, GIF, WebP, AVIF, SVG, BMP, ICO, TIFF, HEIC or JPEG XL file does. Text to Base64 takes a file of any other kind, up to 5 MB.”
  • “This is a video, not a picture.”
  • “This is a PDF, not a picture.”
  • “This file is packed with gzip, and what is inside is not an SVG.”
  • “This file is empty.”

Pasting a picture, a copied file or the code of an SVG

Press Ctrl+V anywhere on the page to take what’s on the clipboard. What arrives depends on what you copied. In testing in Chrome 158 on Linux, a file copied in a file manager came over as the file itself, and a picture copied as a picture came over as a PNG of its pixels. The code of an SVG copied as text, pasted outside the page’s text boxes, becomes a picture called pasted.svg.

Under the box, after the word or, there’s also a button: Paste a picture. It’s meant for where there’s no Ctrl+V, as on a phone or a tablet. It shows only in a browser that lets a page read the clipboard, and your browser may ask you to allow that first. It takes a picture, which becomes pasted.png, or the code of an SVG, which becomes pasted.svg, but no files. The button was tried on a desktop computer in Chrome 158 and Firefox 158. Phones and tablets weren’t tried.

With nothing it can take on the clipboard, the button gets “There is no picture on the clipboard that your browser hands to a page. Copy a picture, or the code of an SVG, and press the button again. A file copied in a file manager is taken with Ctrl+V only.” If the browser says no, the page says “Your browser did not let the page read the clipboard. Allow it when your browser asks, or choose the picture as a file.”

Measured in Chrome 158 on Linux, with another program holding the clipboard:

What was copied With Ctrl+V With Paste a picture
A picture offered as a PNG image.png, the very bytes offered pasted.png, the same bytes
A picture offered only as a JPG nothing arrives nothing arrives
A JPG file copied in a file manager the file itself, byte for byte, with its name nothing arrives
A photo with its place and camera details, copied in a file manager the file itself, details and all nothing arrives
An SVG file, or two files, copied in a file manager each file itself nothing arrives

So a picture pasted as a picture never arrives as a JPG, and for a photo that matters. Saved as PNG, the pixels of 30 photos from real cameras and phones took 4.6 times the bytes of their JPG files, from 0.3 to 10.2 times per photo. A test photo of 56.7 KB, copied as a picture, arrived as a PNG of 530.3 KB. The card of a picture pasted as a picture says:

This picture was pasted as a picture, not as a file. What comes off the clipboard is a PNG of its pixels, whatever file the picture came from: a JPG never arrives as a JPG. So this is the text of that PNG, and for a photo that PNG is mostly several times the size of the JPG. For the text of a file itself, choose the file.

The text you need: Base64, a data URL, or a line of HTML, CSS, Markdown or JSON

Write each picture as offers six forms, and one choice applies to every picture on the page. Under the choice, the page says what it’s for. For icon.png, the forms give:

Choice What the card holds Saved as
A data URL data:image/png;base64,iVBORw0… icon-data-url.txt
Base64 only iVBORw0… icon-base64.txt
An HTML image tag <img src="data:image/png;base64,…" alt="" width="32" height="32"> icon.html
A CSS background .icon { background-image: url("data:image/png;base64,…"); }, on three lines icon.css
A Markdown image ![icon] directly followed by (data:image/png;base64,…) icon.md
A JSON string "data:image/png;base64,…" icon.json

A data URL is where the page starts. A data URL (also called a data URI) is “The Base64 with the kind of picture in front, as in data:image/png;base64,… It goes wherever the address of a picture goes.” Choose it for the src of an image, a url() in a style sheet, or anything else that takes the address of a picture.

Base64 only is “The bare Base64 of the file, with nothing in front. For a field or a program that asks for Base64 and is told the kind of picture some other way.” With this choice a tick appears: Break the Base64 into lines of 76 characters, as email asks for. The lines are joined by line feeds, and the size line then adds “Each line break counts as a character.”

An HTML image tag is “A whole <img> tag with the data URL as its src, and with the width and height of the picture where it has them. What you write in the box on a card goes into its alt.” The width and height are the picture’s size as the browser shows it. A phone photo stored lying down but marked to be shown upright gets its upright size: in testing, a 4,608 × 3,456 photo with that mark got width="3456" height="4608". A picture your browser can’t show gets no width and height. Nor does an SVG that gives itself no size in pixels, and its card says “This SVG gives itself no size in pixels, so the image tag has no width and height. Set them where you use it.”

A CSS background is “A rule that sets the picture as a background. Its class is named after the file.” The class name uses plain lower-case letters, digits and hyphens. A name that begins with a digit gets img- in front, and two files that would get the same name become .icon and .icon-2. In testing, My Logo 2024.png became .my-logo-2024 and 2024 banner.png became .img-2024-banner.

A Markdown image is “An image in Markdown, with the data URL as its address. Its description is what you write in the box on a card, or else the name of the file.” Markdown programs don’t all take a data URL for every kind of picture. In testing, markdown-it 14.1.0 made a picture only of PNG, JPG, GIF and WebP, and left the other kinds as plain text, while Python-Markdown 3.5.2 took all of them. So for the other kinds the card says, for example: “Markdown programs differ. Some take a data URL only for PNG, JPG, GIF and WebP pictures, and would leave this SVG as plain text.”

A JSON string is “The data URL as a JSON string, in double quotes. Several pictures together become one object, with the names of the files as keys.”

Change the choice at any time: every card is written again in the new way. As the page says, “These choices are remembered on this device and nowhere else. Your pictures never are.”

Alt text for the image tag and the Markdown image

With An HTML image tag or A Markdown image chosen, each card has a box, What the picture shows (its alt text). Under it the page says: “Read out to visitors who cannot see the picture. Leave it empty for a picture that is only decoration.”

What you type goes into the text a moment after your last key. In the image tag it goes into alt, with ", <, > and & written so that they’re safe inside the quotes. Typed as The "Seoperc" logo <new> & blue, it gives:

<img src="data:image/png;base64,…" alt="The &quot;Seoperc&quot; logo &lt;new&gt; &amp; blue" width="32" height="32">

In a Markdown image it takes the place of the file’s name, with square brackets marked by a backslash. Typed as A blue square [icon], it gives ![A blue square \[icon\]], followed by the data URL in round brackets. With the box empty, the tag keeps alt="" and the Markdown image keeps the name of the file.

Copy, Save as a file, Copy all of them and Save all in one file all carry it. The box takes up to 300 characters on one line. It isn’t remembered: a new choice of pictures starts with empty boxes. The other four forms have no place for a description, so they show no box.

What each card tells you

Each card shows a small copy of the picture, its name, and its facts, such as “PNG, 32 × 32 pixels, 211 bytes” or “JPG, 3,264 × 2,448 pixels, 811.9 KB”. A KB here is 1,000 bytes, and an MB is 1,000,000. Below that are two lines about size:

  • “This text: 306 characters, 45% more than the 211 bytes of the file.”
  • “Packed with gzip, as web servers send text: about 279 bytes for this text, 234 bytes for the file itself.”

The second line is worked out in your browser, with its own gzip, from the very text in the box. So each form has a figure of its own. For the icon above:

Form Packed with gzip
A data URL 279 bytes
Base64 only 258 bytes
Base64 only, in lines of 76 264 bytes
An HTML image tag 312 bytes
A CSS background 316 bytes
A Markdown image 291 bytes
A JSON string 282 bytes

Then comes the text itself. Up to 100,000 characters it’s shown whole. A longer text is shown by its beginning and end, and the page says, for example, “Shown: the first 2,000 and the last 200 of 1,332,406 characters. Copy and Save give all of them.” The button reads Save as a file with the file’s name beside it, such as (icon-data-url.txt), and the saved file ends with a line break.

Last comes the check. Before a text is shown, your browser decodes it again with its own Base64 reader and compares the result with the file. Then the card says:

Checked: decoded again by your browser, this text gives back the file, byte for byte.

If that ever failed, the text wouldn’t be shown at all. The card would say “The check failed: decoded again by your browser, this text did not give back the file. It is not shown.”

Why Base64 makes an image a third larger

Base64 makes every image about a third larger, because it writes each 3 bytes as 4 characters. The page explains:

Base64 writes every 3 bytes of a file as 4 characters, chosen from 64 that pass wherever text does. So the text is a third longer than the file, and it holds the file itself: decoded, it gives the same bytes. Nothing about the picture changes and nothing is left out. An animation still moves, and what a camera wrote into a photo is still there.

A small file shows more than a third, because the label of a data URL counts too: data:image/png;base64, is 22 characters. That’s why the 211-byte icon above comes out 45% larger.

What travels over the network is often smaller. As the page says, “Web servers send text packed.” The Base64 of a picture that is already packed, such as a JPG, WebP or GIF, shrinks back to almost the size of the file. Measured on real files, packed at gzip’s usual strength:

Files Size of the files As Base64 data URLs The data URLs packed with gzip
30 photos from real cameras and phones (JPG) 15,804,945 bytes 21,073,994 characters (33.3% more) 15,825,466 bytes (0.13% more than the files)
4 WebP pictures 239,490 bytes 319,420 characters (33.4% more) 241,170 bytes (0.7% more)
67 GIF pictures 7,545,785 bytes 10,062,622 characters (33.4% more) 7,609,355 bytes (0.8% more)

Lines of 76 pack a little worse than one long line: the Base64 of the same 30 photos came to 1.75% more, packed, when it was broken into lines.

An SVG is the exception: its Base64 packs far worse than the SVG itself. The next section shows the way round that.

A data URL also changes how the picture travels. The page’s Good to know box says: “The picture is then part of that page or style sheet and needs no request of its own. It also travels with that file every time the file is sent: a browser cannot keep it apart, as it keeps a picture that is a file of its own.”

SVG to data URI: written as text, not Base64

An SVG can go into a data URL as plain text, without Base64, and that’s shorter for nearly every SVG. Tick Write an SVG as text, not as Base64, where that is shorter. It starts off. The page explains:

An SVG is text already. With only its awkward characters spelled out it is shorter than its Base64 for most SVG files, and a browser reads the same picture from it.

While the tick is off, an SVG’s card says what it would save, beside a button Write SVG as text: “As text, not Base64, the data URL of this SVG would be 63 characters shorter: 635 in place of 698.”

The text form keeps the bytes of the file. Letters, digits, spaces, single quotes and the marks - _ . ~ = : / , ; ! * ( ) + stay as they are. Every other byte is spelled %XX, among them <, >, ", #, %, &, line breaks, tabs and the bytes of any letter outside plain English ones. So the text begins like data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' ….

The double quotes around values in the SVG become single quotes, which mean the same in XML and need no spelling out. That happens only where the file is built as XML asks, where your browser’s own XML reader builds the same tree from the result, and where your browser draws the same picture from the data URL as from the file. A value that holds a single quote keeps its double quotes. Quotes in the words of the drawing, in a style sheet, a script, a comment or a DOCTYPE are never touched. The check line then says how many values changed:

Checked: your browser draws the same picture from this text as from the file. Decoded again, the text differs from the file only in the quotes around 23 values: single in place of double, which says the same in an SVG.

The card also says “Written as text: 63 characters shorter than its Base64 would be.” With A data URL chosen, it adds “The data URL holds spaces and single quotes. Keep double quotes around it, as in src="…" or url("…").” In An HTML image tag, A CSS background and A JSON string, the page writes those double quotes itself.

Some SVG files stay Base64:

  • Base64 only and A Markdown image always use Base64. A Markdown address ends at the first space.
  • An SVG full of Japanese words, or of other letters outside plain English ones, can be longer as text. In testing, one gave “As text this SVG would be longer than its Base64 (1,319 against 682 characters), so it stays Base64.”
  • An SVG stored as UTF-16 stays Base64: “This SVG is stored with two bytes for each letter (UTF-16). Written as text it would be far longer than its Base64, so it stays Base64. Saved as UTF-8, the file itself would be about half the size.”

Measured on the 7,305 SVG icons of a Linux desktop:

7,305 SVG icons Characters Packed with gzip
As Base64 data URLs 32,252,874 12,345,557 bytes, 68.7% more than the files packed
As text data URLs 25,728,077 (20.2% fewer) 7,520,273 bytes, 2.8% more than the files packed

Every one of the 7,305 was shorter as text. Packed, the gap grows, because an SVG repeats the same words over and over, and Base64 spells each repeat differently depending on where it falls in the groups of 3 bytes, so gzip finds far fewer repeats. Python’s XML reader read the same from each file before and after the quotes were swapped. And 300 of the icons, put through the page itself in Chrome, were all drawn the same from their text as from the file.

An SVG written as text is the SVG’s own code with some characters spelled out, so keep the SVG file itself: the Base64 tools listed below don’t turn that text back into the file.

Notes a card can carry

A card adds a note when there’s something you should know before you use the text. The note on a pasted picture is quoted above, under pasting.

When your browser can’t show a kind of picture, the text is still the file, but there’s no preview and no size:

Your browser cannot show a HEIC picture, so there is no preview and no size here. The text is right all the same: it holds the file itself. A page that uses it shows the picture only in a browser that can show HEIC.

In testing, Chrome 158 and Firefox 158 showed PNG, JPG, GIF, WebP, AVIF, BMP, ICO, SVG and JPEG XL. Neither showed HEIC or TIFF, and Chromium 147 didn’t show JPEG XL. Safari wasn’t tried.

A PNG, JPG, GIF or WebP file that stops before its end, such as a download that broke off, gets for example “This file does not end the way a PNG file should: it may be cut short or damaged. The text holds the file as it is.” When your browser can’t open a picture of a kind it shows at all, the card says “Your browser could not open this picture: the file may be damaged, or larger than your browser can show. The text holds the file as it is.”

An SVG that says it’s stored as something other than UTF-8 gets, for example, “This SVG says it is stored as ISO-8859-1. Your browser does not show such a file as a picture in a page, so its data URL shows nothing here either. Saved as UTF-8 it would show. The text holds the file as it is.” In testing, Chrome 158 didn’t show such an SVG in a page, whether it came from a file, a server or a data URL, while Firefox 158 did. Another SVG the browser can’t draw gets “Your browser does not show this SVG as a picture: it may hold a fault. The text holds the file as it is.”

Everything in the file goes into the text, including what a camera wrote into a photo, and the card says so:

This picture says where it was taken. That is part of the file, so it is in the text too, and in every page the text goes into.

Other details are named, for example “The file holds more than the picture: when it was made, the camera or phone, the program it was made with. That is in the text too.” A link follows: The Metadata (EXIF) Remover takes such details out of a picture first.

Converting many images at once

Choose or drop up to 100 pictures at once. Choose more, and the page tells you how many you chose and that “The first 100 were taken.” A new choice replaces what’s on the page.

With two or more pictures, a bar sums them up in two lines. For eight test pictures as data URLs:

Pictures: 8. Their files together: 284.7 KB. As text: 379,818 characters.

Packed with gzip, all these texts in one file: about 223.2 KB. The files themselves, packed one by one: 218.5 KB.

The second line comes a moment after the texts are ready. It packs the very text that Copy all of them gives, so it follows the form you chose and your alt text. Texts that repeat each other pack together to very little: 100 copies of one icon came to about 452 bytes, against 23.4 KB for the files packed one by one. The line is left out when the texts together come to more than 150 million characters.

Files that weren’t pictures are counted too, as in “Files left out: 1.” Two buttons work on all of them:

  • Copy all of them puts every text on the clipboard, one to a line, with an empty line between CSS rules and between Base64 texts broken into lines.
  • Save all in one file saves them as images-data-url.txt, images-base64.txt, images.html, images.css, images.md or images.json, after the form you chose.

The alt text you typed on each card goes along. As JSON, the pictures become one object with the names of the files as keys. A second file with the same name gets a number after its name, as in icon.png (2). Shortened here:

{
  "icon.png": "data:image/png;base64,iVBORw0KGgo…",
  "logo.svg": "data:image/svg+xml;base64,PD94bWwg…"
}

Example

A PNG icon, icon.png, with A data URL chosen. Its card says:

  • “PNG, 32 × 32 pixels, 211 bytes”
  • “This text: 306 characters, 45% more than the 211 bytes of the file.”
  • “Packed with gzip, as web servers send text: about 279 bytes for this text, 234 bytes for the file itself.”
  • “Checked: decoded again by your browser, this text gives back the file, byte for byte.”

And the text, all 306 characters:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAmklEQVR42u1XwRGAIAyj+etKOoBOqwPoSjqALoBCa4u9A55wJCH0IA2h9kHcDdNwXG/r696TiYAUsVQIaRNzhcCSPAcDluQ5WLAmT2GShHzZuuj8PJ7smsDf7wCsrU857MeBEqePcfmqgSagCahbADfJaGUEX1dQwgV3vyGVCiRPDkMjWn8Jp9DK99JkDM0mQ4LhvzGxbs3auAE6okcytiILcgAAAABJRU5ErkJggg==

With A CSS background, the same icon gives this rule of 346 characters:

.icon {
    background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAmklEQVR42u1XwRGAIAyj+etKOoBOqwPoSjqALoBCa4u9A55wJCH0IA2h9kHcDdNwXG/r696TiYAUsVQIaRNzhcCSPAcDluQ5WLAmT2GShHzZuuj8PJ7smsDf7wCsrU857MeBEqePcfmqgSagCahbADfJaGUEX1dQwgV3vyGVCiRPDkMjWn8Jp9DK99JkDM0mQ4LhvzGxbs3auAE6okcytiILcgAAAABJRU5ErkJggg==");
}

With An HTML image tag and nothing in the alt box, it’s a tag of 348 characters, ending alt="" width="32" height="32">. With the alt text from the section above, it’s 399 characters, and packed with gzip about 350 bytes.

An SVG logo, logo.svg, 48 × 32 pixels and 502 bytes, is 698 characters as a Base64 data URL. After Write SVG as text, it’s 635 characters, and packed with gzip it comes to 381 bytes in place of 500. The file itself packs to 351. The text begins:

data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%0A%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='32' viewBox='0 0 48 32'%3E%0A  %3Ctitle%3ECaf%C3%A9 …

How long it takes

Measured in Chrome 158 on a desktop computer (AMD Ryzen 9 3950X), three runs each. Ready counts from choosing the files to every text being ready: read, checked, packed sizes worked out and small copy drawn. Copied counts from the click on Copy, or Copy all of them, to the text being on the clipboard.

Pictures Ready Copied
A PNG icon of 211 bytes, the first picture of a visit 0.04 to 0.05 s 0.01 s
An SVG logo of 502 bytes, as text 0.03 s 0.01 s
A phone photo, JPG of 2.0 MB (3,264 × 2,448) 0.19 to 0.20 s 0.02 s
A 12 megapixel JPG of 2.5 MB (4,032 × 3,024) 0.25 to 0.27 s 0.02 s
A 48 megapixel JPG of 7.8 MB (8,064 × 6,048) 0.83 to 0.84 s 0.05 s
A PNG of 5 MB 0.31 to 0.32 s 0.04 s
A PNG of 20 MB 1.2 s 0.11 to 0.12 s
A PNG of 50 MB (66.7 million characters) 3.0 to 3.1 s 0.29 to 0.30 s
30 camera photos at once, 15.8 MB together 1.5 to 1.6 s 0.12 to 0.13 s (all of them)
100 small PNG icons at once 0.34 to 0.35 s 0.02 to 0.03 s (all of them)

With several pictures, the packed line of the bar followed after 2.1 s for the 30 photos and after 0.39 to 0.40 s for the 100 icons. In Firefox 158, one run each, 5 MB was ready after 0.4 s, 20 MB after 1.3 s and 50 MB after 2.8 s.

How large a picture can be, and other limits

How large a picture can be depends on the longest text your browser can hold. In Chromium 147 on a desktop computer that’s about 536 million characters, the Base64 of about 402 MB. In testing, files of 100 MB were ready after 6.5 s and 200 MB after 12.6 s. Files of 300 MB and 400 MB were ready after 3.9 s and 6.1 s, but without the packed sizes and the note on what the file holds: the page left those out. They were still checked, copied and saved, and 400 MB was copied in 1.9 s. A file of 410 MB was refused with:

This file is too large: its Base64 would be longer than the longest text your browser can hold.

Phones weren’t tried, and they have far less memory.

Long data URLs work in a page. In testing, the data URL of a 50 MB PNG, 66,729,446 characters, showed the picture as the address of an image in both Chrome 158 and Firefox 158. No limit was met.

Other messages you may meet:

  • When several texts together are too long for Copy all of them: “Together these texts are longer than the longest text your browser can hold. Save them in one file, or copy them one by one.” Save all in one file writes the file piece by piece, so it can be longer than the browser’s longest text.
  • When the browser won’t let the page copy: “Your browser did not let the page write to the clipboard. Save the text as a file.”
  • When a picture is dragged over from another web page: “That was the address of a picture, not the picture itself. Save the picture to your device and choose the file, or copy the picture and paste it here.” The page can’t fetch pictures from a web address.
  • When a file can’t be read: “Your browser could not read this file.”

The page never makes a picture smaller. The text always holds the file as it is, so to get a shorter text, start from a smaller file.

Which tool for which job

To get a picture back, the first three tools below take a Base64 data URL or bare Base64, with or without line breaks. Paste just that. In testing, Base64 to Text turned the image tag, the CSS rule, the Markdown line, the JSON string and an SVG written as text into a decoded.bin that isn’t the file, and the other two refused the image tag and an SVG written as text.

  • Get the very file back, whatever its kind: Base64 to Text. In testing it gave back PNG, JPG, WebP, GIF and SVG files byte for byte. An AVIF or a BMP came back byte for byte too, but named decoded.bin.
  • Make a PNG picture of Base64: Base64 to PNG. It gives a PNG whatever went in: the same file for a PNG, a PNG made of a JPG or a WebP, one frame of a moving GIF. It refuses an SVG.
  • Make a JPG picture of Base64: Base64 to JPG. It makes a JPG anew, even from the Base64 of a JPG, and it refuses an SVG too.
  • Turn any other file into Base64, up to 5 MB, or get URL-safe Base64: Text to Base64.
  • Make the picture smaller first, for a shorter text: Image Compressor.
  • Take the place and camera details out of a photo first: Metadata (EXIF) Remover.

FAQ

Are my images uploaded when I convert them to Base64?

No. The pictures are turned into text in your browser and never leave your device. In every test run, the page sent nothing while it worked.

Why is the Base64 bigger than the image?

Base64 writes every 3 bytes as 4 characters, so the text is a third longer than the file, and a data URL adds its label, such as the 22 characters of data:image/png;base64,. Packed with gzip, as web servers send text, the Base64 of a JPG, WebP or GIF comes back to within 1% of the file’s own size in testing.

What is the difference between Base64 and a data URL?

A data URL is the Base64 with the kind of picture in front, as in data:image/png;base64,, so it can go wherever the address of a picture goes. Bare Base64 is for a field or a program that asks for Base64 and learns the kind of picture some other way.

How do I use a Base64 image in HTML or CSS?

Choose An HTML image tag to get a whole <img> tag with the data URL as its src, the picture’s width and height, and the alt text you type on its card. Or choose A CSS background to get a rule that sets the picture as background-image, then copy it into your page or style sheet.

Should I use Base64 for an SVG?

Usually not: an SVG written as text in a data URL is shorter, and the page writes it that way when you tick Write an SVG as text, not as Base64, where that is shorter. On 7,305 SVG icons, the text form was 20.2% shorter than Base64, and packed with gzip it came to 2.8% more than the packed files, against 68.7% more for Base64.

Is there a size limit for a Base64 image?

The only limit is the longest text your browser holds: in testing, Chromium 147 on a desktop computer took a 400 MB file and refused one of 410 MB. A data URL of 66.7 million characters, from a 50 MB PNG, still showed as a picture in Chrome 158 and Firefox 158.

Does converting to Base64 lower the quality or remove EXIF data?

No. A file you choose goes into the text byte for byte, and your browser decodes the text again and compares it with the file before it’s shown. Camera details and the place a photo was taken stay in the text too, so take them out first with the Metadata (EXIF) Remover if you don’t want them shared.

Can I convert an image URL or a copied image to Base64?

Not from a URL: the page works only in your browser, and a picture dragged from another web page arrives as its address, so save the picture and choose the file. A file copied in a file manager and pasted with Ctrl+V comes over as the file itself, as it did in Chrome 158. A picture copied as a picture arrives as a PNG of its pixels, often several times the size of a JPG, so for the text of the file itself, choose the file.

How do I turn Base64 back into an image?

Paste the Base64 data URL or the bare Base64, with or without line breaks, into Base64 to Text to get the very file back, whatever its kind. Base64 to PNG always gives a PNG and Base64 to JPG a JPG, and neither takes an SVG. An SVG written as text doesn’t go back through these tools, so keep the SVG file.

Note: All processing is done client-side. We do not store or see your data.

Related Tools

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us