Image to Base64 Converter
This image to Base64 converter turns a picture into a Base64 string you can copy straight away as a data URL, HTML tag, CSS background, Markdown or JSON. It can shrink the image or convert it to PNG, JPG or WebP first. In the other direction, the decoder shows the image behind any Base64 text and saves it as a file.
Source: RFC 2397, RFC 2397 – The "data" URL scheme. Updated: .
How it is calculated
How to convert an image to Base64
- Drag in an image, choose it or paste it with Ctrl + V. The Base64 code appears immediately.
- Pick the output: a data URL for
srcorurl(), Base64 only for APIs, a ready-made HTML img tag with width and height, a CSS line forbackground-image, Markdown or JSON. - Copy it or save it as a text file.
A data URL follows RFC 2397: data:image/png;base64, followed by the image bytes in Base64 as defined in RFC 4648. The MIME type is detected from the file content, not the extension, so a PNG named .jpg still gets image/png.
How big does an image get in Base64?
Base64 turns every 3 bytes into 4 characters, so the text is about 33% larger than the file: a 30 KB image becomes roughly 40,000 characters. That is why Base64 is best for small graphics such as icons, logos, placeholders in emails, self-contained HTML files and CSS. Shrink large photos first with “Resize to width”, or convert them to WebP or JPG.
Base64 back to an image
In “Base64 → image” mode, paste a data URL, a whole CSS line, an HTML img tag or just the Base64 text – with line breaks, without the trailing equals signs or in the URL-safe variant with - and _. The tool recognises JPG, PNG, GIF, WebP, BMP, TIFF, AVIF, HEIC, SVG and ICO, shows the size and dimensions and saves the file with the right extension. If the type in the data URL does not match the actual content, you get a note.
Privacy and limits
Images and pasted text stay in your browser; nothing is uploaded or stored. Images up to 10 MB can be encoded; SVG and ICO are kept as they are. To encode any text or file, use Base64 encode and decode; to change an image’s format, the image converter, and to make it smaller, compress the image.
Frequently asked questions
How do I convert an image to Base64?
Choose the image here and the code appears instantly. As a data URL it starts with data:image/…;base64, and can be used directly in HTML or CSS.
How do I embed a Base64 image in HTML?
Choose the “HTML ” output and copy it:
<img src="data:image/png;base64,…" alt="…">. The tool adds width and height for you.
How do I convert Base64 back to an image?
Switch to “Base64 → image”, paste the text and click “Show image”. The picture appears and can be saved with the correct file extension.
Why is the Base64 string bigger than the image?
Base64 represents every 3 bytes with 4 text characters, so the string is about one third larger than the image file.
Can I convert an SVG to Base64?
Yes. SVG is encoded unchanged with the type image/svg+xml, for example for CSS backgrounds.
Is my image uploaded?
No. Encoding and decoding run entirely in your browser, and nothing is stored.
Sources and legal basis
- RFC 2397: RFC 2397 – The "data" URL scheme
- RFC 4648: RFC 4648 – The Base16, Base32, and Base64 Data Encodings (§ 4 Base64, § 5 Base64url)
- MDN – data: URLs
- ITU-T T.81 / ISO/IEC 10918-1 – JPEG
- W3C – Portable Network Graphics (PNG) Specification
- Google for Developers – An image format for the Web (WebP)
- AOMedia – AV1 Image File Format (AVIF)
- MDN – Image file type and format guide
- MDN – HTMLCanvasElement.toBlob()
As of: · Editorial policy
Related tools
- Base64 Encode and DecodeEncode and decode Base64 and Base64url with proper UTF-8, plus URL encode/decode (percent-encoding). Clear error messages, runs locally in your browser.
- Image converter: JPG, PNG, WebP, AVIFImage converter without upload: PNG to JPG, WebP to JPG, HEIC to JPG, plus AVIF, BMP and ICO – up to 20 images at once, resize, ZIP download. Free.
- Compress images – reduce file sizeCompress images without uploading: shrink JPG, PNG, WebP and HEIC, up to 20 at once, with an optional target size in KB and ZIP download. Free.
- Resize imagesResize images online by pixels or percent, keep the aspect ratio or crop to fit, with presets for Instagram and YouTube. Up to 20 images, no upload.
- Favicon generator: from image, text or emojiCreate a favicon from an image, letters or emoji: favicon.ico (16/32/48), apple-touch-icon, PNG 192/512, site.webmanifest and HTML code. No upload.
- QR Code Generator – free and permanentQR code generator for links, Wi-Fi, contacts (vCard), email, SMS or phone – add colors and a logo, download PNG or SVG. Never expires, no tracking, no sign-up.
- Pt to mm converterPt to mm converter: 1 pt = 0.3528 mm (1/72 inch). Convert font sizes to millimeters, picas, inches and pixels at any resolution, with a size table.
- Find duplicate photos and clean upFind duplicate photos: pick your images, group identical and similar shots, mark duplicates and download a cleaned ZIP. Photos never leave your device.
- HTML to Image ConverterHTML to image: paste your code, choose width and resolution and save a PNG, JPG or WebP – also transparent. Free, no upload, runs in your browser.