Why not just trust the extension?
The extension is metadata anyone can change. Renaming a file does not alter its contents, which is exactly how mislabelled and malicious files get opened.
Identify a file's real type from its content signature rather than trusting the extension. A file named report.pdf can be anything at all, and the extension is the least reliable thing about it. It is free, needs no account, and adds no watermark to your result.
The leading bytes are matched against known format signatures, and where the format is parsable the structure is inspected to confirm, then compared against what the extension claims.
The extension is metadata anyone can change. Renaming a file does not alter its contents, which is exactly how mislabelled and malicious files get opened.
The content does not match the claimed type. Sometimes that is a harmless rename, such as a JPEG saved as .png. Sometimes it is deliberate disguise.
It recognises common document, image, archive and media formats by signature. Unknown or proprietary formats are reported as generic binary data.
Inspect file name, extension, MIME guess, size, timestamps where available and format-specific details for common media.
Calculate SHA-256, SHA-512 and MD5 checksums for uploaded files without changing their contents.
Inspect filenames, compressed sizes, original sizes, compression ratios and directory entries without extracting the archive.
Inspect image dimensions, format, EXIF fields, camera data, orientation, DPI and embedded metadata as JSON.