DEV Community

Muhaymin Bin Mehmood
Muhaymin Bin Mehmood

Posted on Fully Autonomous

Why Does Chrome Save Images as .jfif? (It's a JPEG Wearing a Different Name)

You right-click an image in Chrome or Edge, choose "Save image as", and get photo.jfif. Then a job portal, a marketplace or a CMS refuses it: "Only JPG, JPEG or PNG allowed."

Nothing is wrong with the image. A .jfif file is a JPEG. Only the name is different.

What JFIF actually is

JPEG is the compression method. JFIF (JPEG File Interchange Format) is the most common file layout for storing JPEG data. It adds a small header with things like the version and pixel density. Most files you've ever called "a JPG" are JFIF files inside.

You can check it from the first bytes. Every JPEG starts with FF D8 FF. A JFIF one usually follows with an APP0 segment that literally contains the text JFIF:

async function describe(file) {
  const b = new Uint8Array(await file.slice(0, 12).arrayBuffer())
  const isJpeg = b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff
  const jfif = String.fromCharCode(...b.subarray(6, 11)) === "JFIF\0"
  return { isJpeg, jfif }
}
Enter fullscreen mode Exit fullscreen mode

Run that on a .jfif download and on a .jpg from your camera. Both say isJpeg: true.

So why the weird extension?

The browser asks the operating system which extension belongs to the image/jpeg content type. On many Windows machines the answer is .jfif, because of one registry value:

HKEY_CLASSES_ROOT\MIME\Database\Content Type\image/jpeg
    Extension    REG_SZ    .jfif
Enter fullscreen mode Exit fullscreen mode

You can look at yours without changing anything:

reg query "HKEY_CLASSES_ROOT\MIME\Database\Content Type\image/jpeg" /v Extension
Enter fullscreen mode Exit fullscreen mode

If it says .jfif, that's the whole story. Some installed program changed it, and every browser on that machine now follows it.

Three fixes, from smallest to biggest

1. Rename the file. Change photo.jfif to photo.jpg. The bytes are identical, so this is a complete fix, not a hack. In Windows Explorer you may need View → Show → File name extensions to see the extension.

2. Fix the registry value (affects future downloads). Change Extension to .jpg under the key above. Editing the registry is at your own risk: export the key first so you can restore it.

3. Convert, when renaming isn't possible. Some people can't rename easily (locked-down work laptops, phones, or 40 files at once). Then a converter that re-saves the files as .jpg is the practical route.

Why upload forms reject it

Most upload validation checks the extension or the browser-reported MIME type, not the bytes. accept=".jpg,.jpeg,.png" on an input element filters by extension, so a .jfif file never shows up in the picker or fails the check.

If you build upload forms, two small changes save your users this trouble:

<input type="file" accept="image/jpeg,image/png,.jfif">
Enter fullscreen mode Exit fullscreen mode

And on the server, decide by the first bytes (FF D8 FF for JPEG), not by the name. That also stops the opposite problem: a PNG renamed to .jpg passing your check.

A quick way to do many files

If you have a folder of .jfif files and renaming them one by one isn't fun, BatchSet has a free JFIF to JPG converter. You drop several at once and download a ZIP of .jpg files. It runs in the browser, so the images aren't uploaded.

The short version: .jfif is a JPEG with a Windows naming quirk. Rename it, fix the registry value, or batch-convert. And if you write upload forms, check the bytes, not the extension.

This article was drafted with an AI assistant. The byte check and the registry query were tested before publishing.

Top comments (0)