Base64 JPG Encoder
Convert JPG/JPEG images to Base64 encoded strings instantly in your browser. Free client-side tool with drag-and-drop, quality control, and copy support.
Drop a JPG file here or click to browse
Accepts .jpg, .jpeg files only
About
Base64 encoding translates binary image data into an ASCII string using a 64-character alphabet (A - Z, a - z, 0 - 9, +, /). A raw JPEG file of 100 KB produces a Base64 string approximately 133 KB long due to the inherent 33% size overhead of the encoding scheme. This tool validates JPEG magic bytes (FF D8 FF) before encoding, preventing malformed output from spoofed file extensions. Processing occurs entirely in your browser via the native FileReader API. No data leaves your machine.
Incorrect Base64 strings break inline images in HTML emails, CSS background-image declarations, and JSON payloads. A single missing padding character (=) or a line-break inserted by a naive encoder renders the entire string invalid. This encoder produces specification-compliant output with optional Data URI prefix for direct embedding. Note: Base64 is not encryption. It provides zero confidentiality. Treat encoded strings containing sensitive imagery with the same caution as the original file.
Formulas
The size of a Base64-encoded string is determined by the ratio of 3 input bytes mapping to 4 output characters, with padding to ensure the output length is a multiple of 4.
where Lbase64 = length of the encoded string in characters, and n = number of input bytes. The decoded byte size from a Base64 string can be recovered as:
where p = number of padding = characters (0, 1, or 2). Each group of 6 bits indexes into the Base64 alphabet. The encoding process splits 3 bytes (24 bits) into 4 groups of 6 bits. When re-encoding through Canvas at quality q (0.0 - 1.0), the JPEG encoder applies DCT quantization scaled inversely to q, reducing file size at the cost of visual fidelity.
Reference Data
| Property | Value / Detail |
|---|---|
| JPEG Magic Bytes | FF D8 FF (first 3 bytes) |
| Base64 Alphabet | A - Z, a - z, 0 - 9, +, / |
| Padding Character | = (appended to make length divisible by 4) |
| Size Overhead | ~33.3% larger than binary |
| Data URI Prefix (JPEG) | data:image/jpeg;base64, |
| Max Data URI (IE11) | 4,096 bytes (obsolete browser) |
| Max Data URI (Modern) | No hard limit; practical < 2 MB |
| JPEG Quality Range | 0.0 (worst) - 1.0 (best) |
| Encoding Standard | RFC 4648 ยง4 |
| MIME Type | image/jpeg |
| Typical HTML Usage | <img src="data:image/jpeg;base64,..."> |
| Typical CSS Usage | background-image: url(data:image/jpeg;base64,...) |
| Encoding Time (1 MB file) | < 50 ms (modern browser) |
| Common Use Cases | Email templates, JSON APIs, CSS sprites, offline apps |
| Binary-to-Text Ratio | 3 bytes โ 4 ASCII characters |
| Line Length (RFC 2045) | 76 characters max per line (MIME) |
| URL-Safe Variant | Replaces + with -, / with _ |
| File Extension | .jpg, .jpeg, .jfif |
| Color Space | YCbCr (converted from RGB) |
| Max Dimensions (JPEG) | 65,535 ร 65,535 px |