Home Tools Blog About

How to Tell PNG, JPG, WebP and GIF Apart

The fastest way to tell PNG, JPG, WebP, and GIF apart is to read the first few bytes of the file, called its signature or magic number, not to trust the file extension. A PNG always starts with the same byte sequence, a JPG with another, and so on, no matter what the name says. This guide explains the signatures, why extensions lie, and free tools to check an image’s real type.

Why the extension is not enough

A file extension is just part of the name, and anyone can rename a photo.jpg to photo.png without changing a single byte inside. Programs that trust the extension then fail to open it, while programs that read the real bytes succeed. This is why uploads, converters, and security checks look at the signature instead, since that is the part the file cannot fake just by being renamed.

The four signatures

Each format begins with a fixed marker. PNG starts with the bytes 89 50 4E 47, where 50 4E 47 spells PNG. JPG starts with FF D8 FF. GIF starts with the text GIF, either GIF87a or GIF89a. WebP starts with the text RIFF, then four size bytes, then the text WEBP. Reading those first bytes identifies the format with certainty, which connects to our binary and bytes guide.

Check an image’s real type

Rather than open a hex editor, you can use a checker for each format. The is it a PNG tool, the is it a JPG tool, the is it a WebP tool, and the is it a GIF tool each read the signature and tell you yes or no, all in your browser with no upload.

Which format to keep

Once you know what a file really is, you can decide whether to convert it. WebP is usually the smallest for the web, PNG is best for sharp graphics and transparency, JPG suits photos where small size matters more than perfection, and GIF is mainly for short animations. Our format comparison guide covers the trade-offs in depth.

Free tools used in this guide

Frequently asked questions

How do I tell what format an image really is?

Read its first few bytes, the signature, rather than trusting the extension. A format checker does this and tells you the real type.

What bytes does a PNG start with?

89 50 4E 47, where the 50 4E 47 part spells PNG. JPG starts with FF D8 FF.

Why can a file have the wrong extension?

Because the extension is just part of the name and can be renamed without changing the file’s actual bytes.

How does a WebP file start?

With the text RIFF, then four size bytes, then the text WEBP, so reading the start confirms it is a WebP.

Do the checkers upload my image?

No. They read the file’s first bytes in your browser, so nothing is sent anywhere.

ATV

Written by Nick (ATV Team)

We build and maintain the 600+ free, client-side tools on this site, and every guide is written against the tools themselves: each figure is computed and checked before it is published, and every linked tool is tested in the browser. More about how we work on the about page, and the full library of guides lives on the blog.