File Extension Mismatch Examples
Download a collection of files where the file extension intentionally does not match the actual content type. Includes a PNG image saved as .txt, a JSON file saved as .xml, an HTML file saved as .jpg, and a ZIP archive saved as .pdf. Use these to test file upload validators, MIME type detectors, content-type negotiation, and security-sensitive file handling.
What Is Broken
Each file has a deliberately wrong extension. The magic bytes and internal structure match one format, but the filename suggests another. This creates confusion for applications that rely solely on file extensions for type detection.
Why It Matters
Many security vulnerabilities and data handling bugs stem from trusting file extensions. Proper file type detection should always verify magic bytes and internal structure, not just the filename extension.
Expected Parser / Validator Behavior
MIME type detection libraries should identify the correct type from content, ignoring the extension. Upload validators should flag the mismatch. Web servers should set Content-Type based on content inspection, not extension.
Related Invalid Files
Related Validators & Tools
Frequently Asked Questions
What files are in the pack?
PNG as .txt, JSON as .xml, HTML as .jpg, ZIP as .pdf, and CSV as .json — five common mismatch scenarios.
How do I detect the real type?
Use magic byte detection. Libraries like file-type (Node.js), python-magic (Python), or Apache Tika (Java) read the first few bytes to determine the true format.