Digital Single Lens Reflex (DSLR) cameras save photographs in either a JPEG format (also referred to as JPG) or RAW file format. Most cameras allow you to chose between the two different formats, and in some cases allow the same photograph to be recorded in both formats (one as JPEG and another as RAW). So what's the difference between the two, and is one better than the other?
First we have to understand what the two files types are, and then we have to understand what the goal is.
This is an uncompressed, lossless and unaltered recording of exactly what the photo-sensor detected. Every bit is recorded "as-is" in the RAW file. It has high dynamic range but less contrast. Because of this, it will look washed out and flat in color. You usually need special software to view RAW files, and because they are uncompressed, they are often very large. At first, one would think this is a bad thing, but it's not. I'll explain why in just a minute, below.
This is a compressed and modified alteration of the RAW data from the photo-sensor. The camera has applied post-processing to the RAW data adding sharpness, contrast, and color. Most cameras have various settings that can apply different types of processing such as standard, portrait, vivid, black and white, etc. When a camera saves the photograph as a JPEG, it compresses the file by removing bits of data that don't greatly affect the final image. This reduces the file size considerably, but also means it contain less data. Almost all point-and-shoot cameras, to include smartphones, save pictures in the JPEG format.
So why would anyone shoot in RAW if it looks worse than JPEG?
Almost all professional photographers shoot in RAW, because they want to do their own post-processing in software like Adobe Lightroom or Photoshop, rather than letting the camera do it for them. Furthermore, the RAW file is uncompressed and lossless, which means there is a lot more information to work with as compared to a JPEG file. The increased dynamic range allows colors to be enriched for more so than is possible with a compressed JPEG. Shadows can be lightened bringing out details that would have otherwise been too dark to see. Bright highlights can be darkened to reduce clipping. Once all the desired modifications and post-processing has been made, then the file can be save as a JPEG.
Although it's possible to do this kind of post-processing to JPEG files in Lightroom and Photoshop, it won't yield the same results. Because a JPEG has already had post-processing applied to it, and because it has been compressed (smaller size), a lot of the information has been modified and removed. This greatly reduces any additional modifications a photographer can make when compared to a RAW photo.
However, if the photographer wants a decent looking photograph without the burden of doing all the post-processing themselves, then let the camera do it for you and shoot JPEG (JPG). For example, if you're on vacation taking hundreds of pictures, it could take months to manually apply all the post-processing yourself. Additionally, you can't upload RAW files to Facebook or Instagram.