Base64 to JPG (JPEG) Converter – Free

Convert Base64 to JPG without leaving the page. The tool decodes the string locally, confirms that the bytes open with a JPEG marker, shows the photo and offers it as a download.

How to use the Base64 to JPG tool

  1. Paste the encoded photo into the Base64 or Base64 data URL box. Both a raw string and a data:image/jpeg;base64, value work.
  2. Select Decode file. If the data is not a JPEG you will see an error instead of a result.
  3. Confirm that the Result line ends with image/jpeg and inspect the preview image.
  4. Select Download to store the picture as decoded.jpg.

JPEG markers and how the tool detects them

A JPEG file is a sequence of segments, each introduced by a two byte marker that starts with 0xFF. The first marker is always SOI, start of image, written FF D8. The next segment begins with another FF. This tool therefore accepts decoded data whose first three bytes are FF D8 FF and reports it as image/jpeg.

In Base64 those three bytes become /9j/, which is why every encoded JPEG starts with the same four characters. The characters after them hint at what follows.

  • /9j/4AAQSkZJRg is a JFIF header (marker FF E0), the classic form written by most encoders.
  • /9j/4 followed by a letter from Q to f is an Exif header (FF E1), typical for photos from cameras and phones.
  • /9j/2wBD starts directly with a quantization table (FF DB), common after metadata has been stripped.
  • /9j/7gAO is an Adobe segment (FF EE), written by some image editors.

A worked example: Base64 to JPG header check

Take the 16 characters /9j/4AAQSkZJRgAB. They decode to 12 bytes: FF D8, then FF E0 00 10, then the letters JFIF, a zero byte and 01. That is the start marker plus the opening of a JFIF segment 16 bytes long. The tool accepts it because the first three bytes match. It is only a fragment, so the preview cannot draw a picture, which shows that detection looks at the header and not at the image data.

Input:   /9j/4AAQSkZJRgAB
Bytes:   ff d8 ff e0 00 10 4a 46 49 46 00 01
Result:  12 bytes · image/jpeg
File:    decoded.jpg

Checking that a JPEG string is complete

A well-formed JPEG ends with the EOI marker FF D9. Depending on how the file length divides by three, the Base64 therefore ends in /9k=, in 2Q== or in /Z. If your string ends differently, it was probably cut off by a column limit, a log line limit or a careless copy. The tool will still decode it, and the browser will usually draw the top of the photo and leave the rest blank.

What stays inside the decoded JPG

The download is byte for byte what was encoded. Pixels are not recompressed, so there is no generation loss. Metadata is not removed either: Exif fields such as camera model, capture time, orientation and GPS position remain in the file. Check them before you share a photo that came out of a database or an API.

The file extension is .jpg and the media type is image/jpeg. JPG and JPEG are two names for one format.

Frequently asked questions

Is Base64 to JPG conversion done on my device?

Yes. The browser decodes the string and builds the image in memory. The photo is not transmitted, which matters when the picture is an ID scan or another private document.

What is the difference between JPG and JPEG output?

There is none in the data. This tool saves decoded.jpg with the type image/jpeg. You can rename the file to .jpeg and every viewer will open it the same way.

Why does my string fail with does not contain a JPG file?

The decoded data does not begin with FF D8 FF. It may be a PNG (starts with iVBORw0KGgo), a WebP (starts with UklGR), a HEIC photo from a phone, or text that was encoded twice. Base64 to Image handles PNG, GIF and WebP.

Can I paste a data URL copied from an img tag?

Yes. Paste the full src value. Everything through base64, is dropped before decoding. If the src is percent-encoded, decode that first, because a percent sign is not a Base64 character.

Will the tool rotate or resize the photo?

No. It has no image processing step. Orientation stored in Exif is left as written, and the browser preview applies it the way it would for any JPEG file.

Related tools