Tool guides and practical topics/Images, files and local processingImage Base64 and data URLs: format, size and recoverySeparate bare Base64 from data URLs, calculate encoded length and recover PNG, JPEG, GIF, WebP or BMP with its original bytes and correct extension.Content reviewed · 2026-11-16The problem and contextSmall icons embedded in HTML or CSS often use Base64 inside a data URL. Base64 represents the binary content; the URL adds a media type and encoding marker. A data:image/png;base64, prefix alone does not prove that the following bytes form a PNG. Inspecting the bytes and decoding the image are separate checks.Method and calculationBase64 produces four characters for each group of three bytes. Its padded length is 4 × ceil(n / 3), plus a separate prefix for a data URL. Bare JPEG must be recognized as image/jpeg rather than labelled PNG. Encoding bytes directly avoids canvas re-encoding, preserving animation, transparency and metadata.Worked exampleTwelve bytes produce sixteen Base64 characters; one byte needs four. A restored JPEG downloads as .jpg, while BMP uses .bmp. Copy a complete data URL from the encoder, paste it into the reverse mode and compare the downloaded bytes with the original file. A matching picture alone is a weaker check.ChecklistReduce files larger than 10 MiB first. A separate file URL is often more practical for large images than a long string inside a page. Remove line wrapping when needed, and obtain the original again when its type is inconsistent or decoding fails. Base64 does not hide content or remove location metadata.Image Base64 converterImage to Base64Base64 to imageUp to 10 MiB: PNG, JPEG, GIF, WebP or BMP. Preview: at most 16384 pixels per side and 32 million pixels in total.Image uploadChoose an image fileDrop an image here, or focus a button in this area and paste an image.Read image from clipboardConvert to Base64ClearUse these tools with this articleFile Hash CalculatorGenerate several checksums for one file, copy one or all, download results and compare an expected value. Choose any of MD5, SHA-1, SHA-256 and SHA-512.Image Base64 ConverterEncode PNG, JPEG, GIF, WebP and BMP, or restore the original image from Base64.Image CompressorResize images in your browser, export JPEG, PNG or WebP, compare actual file sizes and choose a JPEG background for transparent areas.Sourceswww.rfc-editor.org · 1www.rfc-editor.org · 2html.spec.whatwg.org · 3