EMZETT.
Login

File extensions and file types: How to recognise files

In short: The file extension (for example .pdf or .jpg) shows which program opens a file; it does not reliably say what is really in the file.

In more detail: After the last dot in the file name comes the file extension. The operating system assigns it to a program: report.docx opens Word, photo.png the image viewer. The actual structure of a file lies in its content, and that can differ from the extension.

In Depth

Common extensions

  • Text: .txt, .md, .pdf, .docx, .odt
  • Spreadsheets: .xlsx, .ods, .csv
  • Images: .jpg/.jpeg (photos), .png (graphics, transparency), .gif, .webp, .svg (vector)
  • Audio: .mp3, .wav, .flac
  • Video: .mp4, .mkv, .mov
  • Archives: .zip, .7z, .tar.gz
  • Programs: .exe, .msi (Windows), .dmg (macOS), .apk (Android), .sh
  • Code: .py, .js, .html, .css

Showing and changing extensions

Windows hides known extensions by default. Enable them in Explorer under View → Show → File name extensions. Renaming an extension does not convert the file: renaming image.png to image.jpg does not make it a JPEG file. To convert you need a program (“Save as”, “Export”, converter).

Security

Dangerous are double extensions such as invoice.pdf.exe (with a hidden extension it looks like a PDF), scripts (.js, .vbs, .bat, .ps1), macros in Office files (.docm, .xlsm) and password-protected archives in emails. Never open unexpected attachments, check the sender and keep extensions visible. With a virus scanner and caution you minimise the risk.

How programs recognise the type

Many files begin with a signature (“magic number”): PDF with %PDF, PNG with \x89PNG, ZIP with PK. The Linux command file name reveals the real type regardless of the extension. Web servers additionally send a MIME type (for example image/png).

See also: Understanding files and folders, ZIP files, Phishing