- What is Base64 encoding for images?
- Base64 is a way to represent binary data (like an image file) as a string of ASCII characters. This lets you embed an image directly in HTML, CSS, or JSON without a separate file request. A data URL adds a header like 'data:image/png;base64,' before the encoded string so browsers know how to interpret it.
- What is the difference between a data URL and raw Base64?
- A data URL includes the MIME type prefix (e.g., 'data:image/png;base64,') and can be used directly in an src attribute or CSS background-image. Raw Base64 is just the encoded string without the prefix, used when you need to pass only the encoded data to an API or store it separately.
- Why does the Base64 string look much larger than the original file?
- Base64 encoding increases file size by roughly 33%, because it represents every 3 bytes of binary data as 4 characters. A 100 KB image becomes about 133 KB as Base64. For this reason, embedding large images as Base64 is generally not recommended for production use.
- Is my image uploaded to a server?
- No. The conversion happens entirely in your browser using the FileReader API. Your image never leaves your device.