File Formats¶
How format detection works¶
Diffract uses three detection methods in order:
- File extension - over 100 extensions are mapped to a format.
- Exact filename - files like
Makefile,Dockerfile,.gitignoreare recognised by name regardless of extension. - Content sniffing - if a file contains a null byte within the first 8 KB, it is treated as binary.
The detected format determines which comparison view opens.
Format table¶
| Format | Extensions / Filenames | Comparison view |
|---|---|---|
| Plain text | .txt, .md, .csv, .log, .yaml, .yml, .json, .xml, .toml, .ini, .cfg, .conf, .env, and 80+ more |
Text (line-by-line) |
| Source code | .js, .ts, .py, .rs, .go, .java, .c, .cpp, .h, .cs, .rb, .php, .swift, .kt, .dart, and more |
Text (line-by-line) |
| Shell scripts | .sh, .bash, .zsh, .fish, .ps1 |
Text |
| Exact filenames | Makefile, Dockerfile, Vagrantfile, .gitignore, .gitattributes, .editorconfig |
Text |
| Binary | Any file containing a null byte; .exe, .dll, .so, .dylib, .bin, .dat, .db |
Hex dump |
| Archive | .zip, .tar.gz, .tgz, .jar |
Archive tree Pro |
| Image | .png, .jpg, .jpeg, .gif, .bmp, .svg, .webp |
Image comparison Pro |
| Excel | .xlsx |
Spreadsheet grid Pro |
| Word | .docx |
Formatted document Pro |
.pdf |
Page text comparison Pro |
Encoding detection¶
For text files, Diffract tries the following encodings in order and uses the first one that produces valid output:
- UTF-8
- UTF-16 LE (with BOM)
- UTF-16 BE (with BOM)
- Latin-1 (ISO-8859-1) - accepted for any byte sequence
Overriding the text encoding¶
If Diffract picks the wrong text encoding for a file (garbled characters are a common sign), click the encoding label in the encoding bar at the bottom of the comparison view, then select the correct encoding from the dropdown. The available options are UTF-8, UTF-16 LE, UTF-16 BE, and Latin-1.
See Encoding & Line Endings for details.
Forcing a comparison type¶
Diffract's format detection is based on file extension and content. If a file is misidentified as binary when it is actually text (or vice versa), the most reliable workaround is to rename it with a recognised text extension (such as .txt) before opening it.