IMAGE BASE64 TOOLOpen converter

Base64 image online

To view a Base64 image online, use a complete data URI, not just the encoded characters. Keep the image type and the comma before the payload. To recover a file, use the decoder. To encode a file, use the image to Base64 converter.

One original image, two representations

We drew this green tile specifically for this page. The sample is an SVG containing a rectangle and a circle. Its source is downloadable, so you can repeat the comparison without using your own private file or relying on a third-party image host.

Original green tile with pale green circle
Our original sample, used for every comparison below.

The first box contains only the encoded file bytes. It does not include the image type or a URL scheme. Giving an image element only those characters makes it a relative URL, rather than an embedded image. Our display test therefore uses a complete wrapper.

PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iODAiPjxyZWN0IHdpZHRoPSIxMjAiIGhlaWdodD0iODAiIHJ4PSIxMiIgZmlsbD0iIzI1NGYzYyIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNDAiIHI9IjIyIiBmaWxsPSIjYzRlNGE4Ii8+PC9zdmc+

The next box contains the same payload after the SVG data URI prefix. The comma separates the description from the encoded bytes. Adding a wrapper does not convert the underlying SVG into a PNG or JPEG. The image type needs to describe the actual file.

data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iODAiPjxyZWN0IHdpZHRoPSIxMjAiIGhlaWdodD0iODAiIHJ4PSIxMiIgZmlsbD0iIzI1NGYzYyIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNDAiIHI9IjIyIiBmaWxsPSIjYzRlNGE4Ii8+PC9zdmc+
Data URI wrapper and payload have different roles

Run the comparison on your device

Press the button to load our complete data URI into an image element. The demonstration also decodes the payload and compares every recovered byte with the original sample. A second image uses a deliberately broken wrapper with the separator comma removed. The displayed results come from your browser, not from a claimed universal compatibility guarantee.

Not run on this device.

Complete data URI

Correctly wrapped sample

Waiting for test.

Missing comma

Deliberately invalid sample

Waiting for test.

Byte integrity and image display are separate checks. A recovered byte match answers whether the payload came back unchanged. It does not establish that the wrapper is valid, that another program accepts it, or that an unknown file is harmless. Conversely, seeing the circle proves that this browser displayed this sample; it does not prove every original byte was preserved.

Byte comparison and image display are separate checks
File byte preservation is separate from image display
Use the original PNG example to compare a complete file round trip.

Repeat the example through the converter

Download our original SVG. Open the home-page converter and leave compression off. Select Data URI when the destination needs a complete image URL. Select Plain Base64 when a destination explicitly requests the payload alone. Copying the HTML option produces a surrounding image tag as well.

The converter's byte check compares decoded output with the bytes used for encoding. With compression off, those are the original file bytes. With compression on, the check covers the exported image bytes instead. This distinction matters because a successful check of an exported file is not evidence that the original metadata or animation survived.

The sample has no external image reference, font dependency or script. Keeping the sample this small makes the broken-wrapper test easier to interpret: both cases share the exact payload, and only the comma changes. The comparison does not reproduce every cause of a missing image on someone else's website.

Is base64 image string safe?

Base64 is reversible encoding, not encryption. Someone with the complete string can recover the image. Do not paste private image data into an unfamiliar service because it looks unreadable. A byte match does not inspect the contents for harmful behavior. Conversion on this site runs locally without sending the input to an API.

What if the image still does not display?

Check the wrapper, the image type and whether the destination supports that image format. A website's content security policy can restrict data images. Our demonstration checks the sample on this page, not every website or email application.

Sources and scope

Question selection used a user-supplied discussion list: “My image is not displaying on website been trying for 2hours” and “Is base64 image string safe”. Their comment bodies were not supplied or read; we do not attribute answers or trends to those threads.

Technical references: MDN data URL syntax and MDN Base64. The sample, comparison and diagrams are original materials for this page.

Same pixels, different Base64 length

A Base64 image represents an encoded image file, not a raw array of pixels. In this controlled PNG experiment, changing only the file compression setting changed the encoded length while preserving the generated pixel array.

We generated a 32 by 24 tile specifically for this test. For coordinates x and y starting at zero, red is x times seven modulo 256, green is y times nine modulo 256, blue is the sum of x and y times five modulo 256, and alpha is 255. This gives a reproducible input rather than an unexplained downloaded image.

The generated array contains 32 × 24 × 4 = 3,072 RGBA bytes. Before compressing, we inserted one zero filter byte at the beginning of each row. The resulting stream contains 24 × (1 + 32 × 4) = 3,096 bytes. Each generated PNG contains a signature followed by IHDR, IDAT and IEND. We changed only the zlib compression level: zero, one, six or nine.

Our level-zero file contains 3,164 bytes. Its IDAT payload contains 3,107 bytes. Encoding the complete file produces 4,220 Base64 characters, or 4,242 characters after adding the PNG data URL prefix. These are measured specimen sizes, not input limits or estimates for an arbitrary image.

Our level-one file contains 2,308 bytes, including 2,251 IDAT payload bytes. Its Base64 value contains 3,080 characters and its data URL contains 3,102. The level-six and level-nine specimens have those same measured lengths. Raising the setting did not make our particular tile smaller after level one. That result does not imply the same behavior for photographs or different software versions.

The complete file-length difference between level zero and level one is 856 bytes. The Base64 payload difference is 1,140 characters. Both measurements come from the saved files, rather than from their visible dimensions. Computing an encoded length from the 3,072-byte pixel array would describe a different input from the complete PNG that we actually encoded.

We reopened each saved specimen with Pillow 12.3.0, converted its image to RGBA and compared the complete array against our generated input. All four comparisons matched. Independently inflating each IDAT stream recovered the same 3,096 filtered bytes. This test therefore distinguishes the stored PNG representation from the pixel array recovered by this named reader.

The zlib runtime used here is 1.3.2. Its compression choices are part of the experiment. Recreating the tile with another encoder may produce a different file length even when the pixels match. That would not invalidate the distinction; it would be a new measurement to record under its own implementation and settings.

To repeat the encoding portion, download a specimen, leave image optimization disabled in the encoder, and encode that complete file. Decode the copied result and compare it against that same specimen. Do not compare a decoded level-zero file against the level-nine file and call the resulting byte difference corruption: those files were intentionally generated through different compression settings.

For this sample we checked full RGBA array equality, not merely matching dimensions or a similar-looking thumbnail. This does not claim that every re-export preserves metadata, animation or color profiles. Our generated inputs contain none of those features, so this experiment cannot establish their preservation.

The practical consequence is narrow: changing how our PNG was compressed changed its Base64 length without changing the recovered RGBA array. Base64 did not choose the PNG compression level. File optimization and representing the resulting bytes as text are separate operations. These saved lengths do not establish HTTP transfer size, browser memory use or page-loading time.

zlib levelPNG bytesIDAT bytesBase64 charactersData URL characters
03164310742204242
12308225130803102
62308225130803102
92308225130803102

Download the generated specimens: compression-0.png · compression-1.png · compression-6.png · compression-9.png

Measured specimen 1 values
Measured values for specimen 1.
Measured specimen 2 values
Measured values for specimen 2.
Measured specimen 3 values
Measured values for specimen 3.
Measured specimen 4 values
Measured values for specimen 4.

Watch the experiment

Watch on YouTube

Related experiment: How to Stream Base64 into UTF-8 Text in Python — watch on YouTube.