Short answer
JPG and JPEG are the same image format. The two spellings are two file extensions for files that follow the same standard, and the image data inside is identical. A photo saved as photo.jpg and the same photo saved as photo.jpeg with the same settings are the same bytes with different names.
Where the name comes from
JPEG stands for Joint Photographic Experts Group, the committee that wrote the standard. It was approved in 1992 as ITU-T Recommendation T.81 and published in 1994 as ISO/IEC 10918-1, and it describes the lossy compression that almost every photo on the web still uses.
Why there are two extensions
Early versions of Windows, built on MS-DOS, only allowed file extensions of up to three characters. JPEG has four letters, so Windows programs saved files as .jpg. Other systems, such as Unix, had no such limit and often used .jpeg. Windows dropped the three-letter limit long ago, but .jpg had become the habit, and today it is the more common of the two.
Both extensions share one official media type, image/jpeg, which is what browsers and servers use to recognize the format. You may also see .jpe and .jif on older files. They are the same format too.
What about .jfif files?
JFIF, the JPEG File Interchange Format, is the container most JPEG files use: a small header that stores details such as the pixel density, followed by the compressed image. Photos from cameras and phones usually use the closely related Exif container instead, which also holds camera settings and sometimes GPS location. Both are JPEG files.
A file that ends in .jfif is an ordinary JPEG with an unusual extension. It sometimes shows up when saving pictures from a browser on Windows. Renaming it to .jpg makes it open in programs and upload forms that don't recognize .jfif, and nothing about the image changes.
When a site accepts only one of them
Upload forms sometimes check the extension and reject a file that is perfectly valid. If a form asks for JPG and you have a .jpeg or .jfif file, renaming it is enough. If the form also has a size limit, use compress image to size to bring the file under 100 KB, 50 KB or any other limit.
Renaming only helps when the file really is a JPEG. A PNG, WebP or HEIC file renamed to .jpg is still a PNG, WebP or HEIC inside, and many programs will fail to open it. Convert it instead with PNG to JPG, WebP to JPG or HEIC to JPG. Our tools read the first bytes of each file to identify its real format, so a mislabeled file is still handled correctly.
Formats with similar names
JPEG 2000 (.jp2) and JPEG XL (.jxl) come from the same committee but are different formats with different compression. Software that opens JPG files often can't open them, so convert them before sharing.
Which extension to use
Use .jpg unless a system asks otherwise. It is the most widely recognized extension, and it describes exactly the same file as .jpeg. What decides the quality and size of a JPEG is how it was compressed. To make an existing JPG smaller, use the JPG compressor.