As a developer, you work with dozens of file formats daily. This cheat sheet provides a quick reference for the most common formats, their MIME types, and when you'll encounter them.
Documents
Format
Extension
MIME Type
Use Case
PDF
.pdf
application/pdf
Document sharing, printing
Word
.docx
application/vnd...wordprocessingml
Word processing
Excel
.xlsx
application/vnd...spreadsheetml
Spreadsheets, data
Text
.txt
text/plain
Plain text, logs
Markdown
.md
text/markdown
Documentation, READMEs
RTF
.rtf
application/rtf
Rich text formatting
Images
Format
Extension
MIME Type
Best For
PNG
.png
image/png
Lossless graphics, UI
JPEG
.jpg
image/jpeg
Photos
GIF
.gif
image/gif
Animations
SVG
.svg
image/svg+xml
Vector graphics
WebP
.webp
image/webp
Modern web images
BMP
.bmp
image/bmp
Uncompressed bitmaps
ICO
.ico
image/x-icon
Favicons
Audio/Video
Format
Extension
MIME Type
Notes
MP4
.mp4
video/mp4
Most compatible video
WebM
.webm
video/webm
Web-optimized video
MP3
.mp3
audio/mpeg
Compressed audio
WAV
.wav
audio/wav
Uncompressed audio
OGG
.ogg
audio/ogg
Open format
Data & Code
Format
Extension
MIME Type
Use Case
JSON
.json
application/json
API data, config
CSV
.csv
text/csv
Tabular data
XML
.xml
application/xml
Legacy data exchange
YAML
.yml
application/yaml
Configuration
TOML
.toml
application/toml
Rust/Python config
Archives
Format
Extension
MIME Type
Notes
ZIP
.zip
application/zip
Most common archive
GZIP
.gz
application/gzip
Single-file compression
TAR
.tar
application/x-tar
Unix archive (often .tar.gz)
Magic Bytes
Each file format has a unique "magic number" at the start of the file that identifies its type:
Format
Magic Bytes (hex)
PDF
25 50 44 46 (%PDF)
PNG
89 50 4E 47
JPEG
FF D8 FF
GIF
47 49 46 38 (GIF8)
ZIP
50 4B 03 04 (PK)
PDF
25 50 44 46
Understanding file formats and their magic bytes helps with file validation, type detection, and security testing.