File formats
What the extension means, what opens it, and the thing about it that actually catches people out.
Image
| Extension | Format |
|---|---|
| .heic | High Efficiency Image Container |
| .webp | WebP Image |
| .avif | AV1 Image File Format |
| .svg | Scalable Vector Graphics |
| .psd | Photoshop Document |
| .ai | Adobe Illustrator Artwork |
| .raw | Camera Raw Image |
Document
Data
| Extension | Format |
|---|---|
| .csv | Comma-Separated Values |
| .json | JavaScript Object Notation |
| .yaml | YAML Ain't Markup Language |
| .sql | SQL Script |
| .parquet | Apache Parquet |
Archive
| Extension | Format |
|---|---|
| .zip | ZIP Archive |
| .7z | 7-Zip Archive |
| .tar | Tape Archive |
| .iso | Disc Image |
Video
Audio
Font
| Extension | Format |
|---|---|
| .ttf | TrueType Font |
| .woff2 | Web Open Font Format 2 |
Executable
| Extension | Format |
|---|---|
| .exe | Windows Executable |
| .dmg | Apple Disk Image |
| .apk | Android Package |
Text
| Extension | Format |
|---|---|
| .log | Log File |
| .env | Environment File |
The extension is a hint, not a fact
A file's extension is just the end of its name — renaming photo.png to photo.jpg changes nothing about the bytes inside. What programs actually rely on is the magic number, the first few bytes of the file: %PDF for a PDF, PK for anything ZIP-based, \x89PNG for a PNG. On Unix, file somefile reports what a file really is regardless of its name.
Formats that are secretly ZIP files
DOCX, XLSX, PPTX, EPUB, JAR, APK and IPA are all ZIP archives with a mandated internal layout. Rename any of them to .zip, extract it, and you can read the XML or class files inside — genuinely useful when a document will not open and you need to recover the text.
Identifying a file by its first bytes
If an extension is missing or wrong, the signature at the start of the file is what actually settles the question. These are the ones worth recognising on sight:
| First bytes | As text | Format |
|---|---|---|
89 50 4E 47 | .PNG | PNG |
FF D8 FF | — | JPEG |
47 49 46 38 | GIF8 | GIF |
25 50 44 46 | %PDF | |
50 4B 03 04 | PK.. | ZIP, and everything built on it |
52 61 72 21 | Rar! | RAR |
1F 8B | — | gzip |
52 49 46 46 | RIFF | WAV or AVI — the next four bytes say which |
00 00 00 .. 66 74 79 70 | ....ftyp | MP4, MOV, HEIC and relatives |
7F 45 4C 46 | .ELF | Linux executable |
4D 5A | MZ | Windows executable — the initials of a DOS engineer |
On macOS or Linux, file something reads these for you. On Windows, certutil -dump or any hex editor will show the first line. A file whose signature does not match its extension is either misnamed or deliberately disguised, and the second case is worth taking seriously in an email attachment.
Choosing an image format
Most "which format should I use" questions come down to three properties: whether the compression throws information away, whether transparency is supported, and whether animation is.
| Format | Compression | Transparency | Use it for |
|---|---|---|---|
| JPEG | Lossy | No | Photographs, where a little quality loss is invisible and the saving is large |
| PNG | Lossless | Yes | Screenshots, logos, anything with sharp edges or flat colour |
| WebP | Either | Yes | The web, where it beats both of the above by roughly 25–30% at the same quality |
| SVG | Not applicable | Yes | Icons and diagrams — it is text describing shapes, so it scales to any size |
| GIF | Lossless, 256 colours | 1-bit only | Almost nothing any more; a short video file is smaller and looks better |
| AVIF | Lossy or lossless | Yes | Smaller than WebP again, with support now broad enough to use with a fallback |
The mistake that costs the most is saving a screenshot as JPEG. Lossy compression works by discarding detail the eye is unlikely to miss in a photograph, and it is exactly wrong for text and sharp edges — you get visible smudging around every letter and a larger file than PNG would have produced. The reverse mistake, a photograph saved as PNG, is merely wasteful rather than ugly.
Converting between them never recovers what was lost. A JPEG re-saved as PNG keeps every compression artefact and simply stops adding new ones; the damage is already in the pixels.
Why the same content has several extensions
Some pairs are genuinely the same format under different names, and some only look that way. .jpg and .jpeg are identical — the three-letter version exists because early Windows filesystems allowed no more. .htm and .html are the same for the same reason. .tif and .tiff likewise.
Others are traps. .doc and .docx are completely different formats: the first is a binary format from the 1990s, the second a ZIP of XML introduced in 2007. .xls and .xlsx differ the same way. Renaming one to the other produces a file that nothing can open, which is the single most common cause of "the file is corrupted" when someone has tried to fix a compatibility problem by editing the name.
Text files and the invisible differences
A plain text file has no header, so nothing inside it declares its encoding or line endings. Two files that look identical can differ in both, and both differences cause real problems.
Encoding is usually UTF-8 now, but files produced by older Windows software may be in a regional codepage, which is why text sometimes arrives with é where é should be — that is UTF-8 bytes being read as Latin-1. A byte-order mark at the start (EF BB BF) marks a file as UTF-8 explicitly, and is helpful to Windows and an annoyance to Unix tools, which will treat it as content.
Line endings are a single newline on Unix and macOS, and a carriage return plus newline on Windows. Git normally hides this from you, and a diff showing every line as changed is the usual sign that it has not.