Use the TinyToolbox Image to Base64 Converter when a form, test fixture, or configuration expects an image as a data URL. A data URL contains the image’s media type and its encoded bytes in one string. For a PNG it typically starts with data:image/png;base64,. The characters after the comma carry the image data.
The converter reads one PNG, JPEG, WebP, or AVIF in your browser and returns text. It keeps the original encoded image bytes. A JPEG remains a JPEG inside the data URL, and an AVIF remains an AVIF. The receiving application must be able to display that image format and accept a data URL in the field where you paste it.
Convert an image and copy the result
- Open the Image to Base64 Converter.
- Choose one image under Image file.
- Select Run tool.
- Check that the result begins with
data:and that its media type matches the image you selected. - Select Copy result to copy the complete data URL.
- Paste it into the destination, then check that the image loads there.
The tool accepts source files up to 4,000,000 bytes. Check the file’s exact size if it is near the limit. A file manager may show a rounded estimate. A file over this threshold is rejected before conversion. If the destination needs only a tiny icon, it is often easier to start with that icon than to encode an entire photo and then try to shorten the resulting text.
The result area shows the URL as text. A long line may wrap on screen, so use the copy button when you need the whole string. If you copy only a selected part, check where the selection begins and ends. Leaving out the last few characters can prevent the receiving app from reconstructing the original image.
Distinguish a complete data URL from its payload
The part before the first comma identifies the representation. The part after it is the Base64 payload. Read the receiving field’s instructions to see which one it expects.
| Destination expects | What to copy |
|---|---|
| An image URL that accepts the data scheme | The entire result beginning with data: |
| Raw Base64 image content | The characters after the first comma |
| A separate media-type field and encoded content | The media type, such as image/png, and the payload in their respective fields |
| A file attachment | The original image file |
For example, a configuration property named “image URL” may accept the full data:image/png;base64,… value. The ellipsis here stands for the real payload. Copy the actual result from the converter. A service that expects raw Base64 and has a separate media-type property may reject the same complete URL. In that case, copy the part after the comma and retain the media type separately.
A JPEG data URL normally uses the media type image/jpeg. The filename can end in either .jpg or .jpeg. If the header looks unexpected, check the type of the source file and whether it was renamed or exported from another format. Editing the header alone does not convert the image bytes.
Estimate how much text an image will produce
Base64 converts every three bytes into four characters. When the input ends with a partial group, the output uses padding as needed. A 3,000-byte image therefore gives 4,000 payload characters, plus the short data URL header. A 75,000-byte image gives 100,000 payload characters. The exact count for any input is four times its byte count divided by three and rounded up to a whole group.
| Source size | Base64 payload length |
|---|---|
| 300 bytes | 400 characters |
| 3,000 bytes | 4,000 characters |
| 12,001 bytes | 16,004 characters |
| 4,000,000 bytes | 5,333,336 characters |
A PNG header of data:image/png;base64, adds 22 characters. For the 3,000-byte PNG example, the complete URL is 4,022 characters. Other media types can give slightly different header lengths. If a form limits the complete string, leave room for the header and any other structure the receiving system counts.
Use a smaller source if the output exceeds a text limit. Cropping or compressing the image first may help if the use permits it. Then encode the new file and verify that its dimensions and appearance still meet the need. Removing arbitrary characters from the payload removes encoded data, and the remaining text cannot be relied on to display the full image.
Test the image in its intended context
Suppose a style setting accepts CSS image URLs and you need a small pattern for an internal prototype. Paste the complete data URL between quotes inside the CSS url() value. Then open the prototype and inspect the element where the image should appear. Check the image itself and whether the style was applied to an element with the intended size.
A valid data URL can still fail to display in a particular app. The field may allow only ordinary web links, the app may restrict data URLs, or its image renderer may lack support for the encoded media type. Try a small PNG you control in the same field to distinguish a field restriction from a problem with the original image. If the field requires a hosted URL, use the normal image workflow for that application.
For a test fixture, verify the exact shape the parser expects. A fixture can require a string containing the full URL, a payload without the prefix, or an object with separate properties. Preserve quotation marks and separators required by the surrounding syntax. When troubleshooting, first inspect the stored value to check whether a form, clipboard step, or line editor truncated it.
Decide whether embedding is useful for each image
Embedding keeps the asset inside the text that refers to it. This works well for a small illustration in a portable example or a fixture that should travel as a single record. You can copy the example without also distributing a companion image file. Check the example in the environment where you intend to share it because some renderers accept a more limited set of URLs.
For a large photo or an image shared across many records, a separate file can make the surrounding text easier to maintain. Imagine 20 records contain the same 3,000-byte icon. Repeating its 4,022-character PNG data URL in all 20 stores 80,440 URL characters before the rest of the records. If the application can use one separate asset, you can update that image once and keep each record shorter. Choose the representation that matches the destination’s actual requirements.
Embedding changes where the image lives. A copied record can contain the full underlying image, even if the receiver sees only a long string. Keep that in mind when sharing a configuration or saving a fixture. Use simple images that are meant to travel with the record. For a format check, a small test graphic can exercise the workflow without sharing a real customer image or document.
Verify the bytes when a handoff requires an exact copy
Encoding leaves the image’s file bytes intact. To check a round trip, copy the Base64 payload and decode it with a tool that writes binary image files. Save the decoded result using the original media type and open it. If the workflow demands a byte-for-byte check, compare the two files with a checksum or a binary comparison. Identical bytes should produce the same checksum with the same algorithm.
The output length is another useful diagnostic. Base64 payloads produced here have a length that is a multiple of four. They may end with one or two equals signs for padding. Preserve those signs unless the receiving format explicitly calls for a different encoding convention. A correct length alone does not prove that every character is intact, especially if the text was manually edited.
Check that you copied from the current result. For two nearly identical icons, the generated strings can start with the same media type while carrying entirely different image data. Replacing an icon in a fixture means updating the payload as well as any descriptive label. Previewing the decoded image or comparing its bytes gives you a stronger check than reading the prefix.
Keep a reproducible record of the conversion
Record the source filename, file type, byte count, and destination field. Note whether that field needs the complete data URL or just the payload. A concise example is “status-dot.png, 300 bytes, complete PNG data URL copied into the prototype’s image field and verified in the preview.” This gives another reader enough information to repeat the steps without copying the result into an unrelated place.
If the image changes, encode the new source and replace the entire old value. Then reopen the destination and inspect the image. For a format change, verify the new media type as part of that check. The header and its payload describe the same file, so keep them together when using the full URL.
Work backward from the destination’s character limit
Suppose an image field accepts at most 10,000 characters and counts the complete PNG data URL. After reserving 22 characters for the header, 9,978 remain. Base64 uses groups of four characters, so the largest payload that fits uses 9,976 characters. That corresponds to 2,494 groups and a source image of at most 7,482 bytes. An image of 7,483 bytes needs one more group, making the complete URL 10,002 characters.
This calculation assumes the limit applies to the data URL alone. If the receiving system counts a whole record, include its other text, delimiters, and any escaping before deciding how much space is available for the image. A limit measured in bytes can also depend on the surrounding text encoding. The Base64 alphabet itself uses ASCII characters, so each payload character occupies one byte in UTF-8. Other fields in the record can contain characters that take more than one byte.
For a concrete test, prepare a PNG smaller than the calculated ceiling, encode it, and paste the full value into the field. Save the record, reopen it, and verify that the image still displays. This second check can catch a field that accepted a paste in the interface but shortened or rejected the value during saving. When testing several images, record the original byte count and the final data URL length together so the next person can compare the result with the same limit.
If a 7,500-byte image just misses the cutoff, return to the image source and make a smaller valid export. Re-encode that export and verify the complete string again. Appending a new header to leftover Base64 text or trimming a few characters might satisfy a superficial length check while still producing a damaged image.