Upload a file
  1. base64hub
  2. Image tools
  3. Base64 to JPG

Base64 to JPG

Paste the Base64 of a photo, with or without the data:image/jpeg;base64, prefix, and save it as a .jpg. The decoded file is the original JPEG byte for byte, metadata included.

Free no sign-up, no limits Local nothing uploaded Exact byte-for-byte original file Updated Oct 27, 2026
Input –Output –Size –

Processed in your browser. This page cannot send your data anywhere – how we know

How to convert Base64 to JPG

  1. Paste the string into the box. Bare Base64 starting with /9j/ and full data:image/jpeg;base64, URIs both work, and so does an <img> tag or CSS rule containing one.
  2. The status line confirms Valid Base64 and Detected JPEG, and the preview shows the photo with its pixel size and file size.
  3. Set a File name and press Download file.

Large photos are fine. A Base64 string of several megabytes can be pasted or opened from a .txt file; anything over 4 MB is decoded without being shown in the text box.

What you get back

Decoding returns exactly the bytes that were encoded. Quality does not change, and nothing is recompressed. That also means everything the original file contained comes back with it:

  • EXIF metadata: camera model, capture time, orientation and, if location was on, GPS coordinates. If you received the Base64 from someone else, the photo may tell you more than they intended. If you are about to pass it on, strip the metadata first, for example with JPG to Base64 and Strip metadata (EXIF).
  • Embedded thumbnails and color profiles.
  • Trailing data after the end of the image. Motion photos from some Android phones append a short video after the JPEG, which is why such a “photo” can be several times larger than expected.

The SHA-256 under the preview lets you prove that the saved file matches a hash you were given.

Telling a JPEG from what only claims to be one

The decoder goes by the bytes and ignores the label. A data:image/jpeg URI holding PNG data, or an API field called photo_jpg that contains WebP, is reported as such: “This looks like WebP, not JPEG”, with a Download as .webp button.

Image CDNs pick the output format from the browser’s Accept header, so an image fetched as photo.jpg and then Base64-encoded in a browser can be WebP or AVIF. An image taken with “Copy image” in a browser usually lands on the clipboard as PNG, even when the page showed a JPEG, so whatever encoded it from the clipboard produced PNG Base64.

If you really need a JPEG, renaming will not help. Save the file in its real format, then convert it with Image to Base64 and Convert to JPEG, and decode that result here.

Spotting a truncated JPEG

JPEG files end with the marker FF D9. Depending on how the file length divides by 3, that gives one of three Base64 endings:

File length mod 3Last bytesBase64 ends with
2FF D9/9k=
1.. FF D9/2Q==
0.. FF D9/Z, usually //Z

A cut-off JPEG still decodes. Browsers draw the part they received, so the bottom of the photo is gray or missing, or a progressive JPEG looks blurry. Typical causes are a database column that is too short, a logger that limits line length and a messaging app that splits long text. Copy the value again from its source.

The same check in Python:

import base64

def check_jpeg(b64: str) -> str:
    data = base64.b64decode(b64.split(",", 1)[-1])
    if not data.startswith(b"\xff\xd8\xff"):
        return "not a JPEG"
    end = data.rfind(b"\xff\xd9")
    if end < 0:
        return "truncated: no end-of-image marker"
    extra = len(data) - end - 2
    return f"complete, {extra} bytes after the end marker" if extra else "complete"

Treat it as a quick test. A camera JPEG carries an EXIF thumbnail with its own FF D9, so a badly truncated photo can still pass. Base64 in Python has more on decoding files.

Common problems

  • “Wrong length” error. One character was lost or added, typically at a line break during copying. Copy the whole value again.
  • Invalid character \. The string came from JSON with escaped slashes (\/9j\/4AAQ...). Run it through Repair Base64 or unescape the JSON first.
  • The photo is huge. Base64 hides how big an image really is: a 4 MB string is a 3 MB photo. The Size row shows the decoded size and the pixel dimensions are listed above the preview.

FAQ

Should the decoded file be .jpg or .jpeg?

Either. Both extensions mean the same format and every program accepts both. The tool uses .jpg; type jpeg into Extension if a system insists on the longer form.

How do I check that a JPEG Base64 string is complete?

A complete JPEG ends with the bytes FF D9, so its Base64 usually ends in /9k=, /2Q== or /Z. A string that ends differently and an image whose lower part is missing both point to truncation.

Can I see the EXIF data of the decoded photo?

The tool does not list EXIF fields, but Show hex dump reveals an Exif block and often the camera maker in the text column. Download the file and open it in an EXIF viewer for the full list.

Why is the decoded photo rotated in some apps?

Phones often store the pixels sideways and record the rotation in an EXIF tag. Browsers apply it, so the preview looks right, but software that ignores the tag shows the raw orientation. The bytes are unchanged either way.