GitShow/sindresorhus/file-type
sindresorhus

file-type

Detect the file type of a file, stream, or data

by sindresorhus
bufferdetectfilefile-typesjavascriptmagicmagic-numbersnodejs
Star on GitHubForknpm

JavaScript

4.3k stars394 forks119 contributorsActive · 1w agoSince 2014v22.0.2MIT

Meet the team

See all 119 on GitHub →
sindresorhus
sindresorhus305 contributions
Borewit
Borewit139 contributions
kevva
kevva19 contributions
mifi
mifi8 contributions
karlhiramoto
karlhiramoto8 contributions
sly7-7
sly7-77 contributions
stroncium
stroncium6 contributions
mceachen
mceachen5 contributions

Languages

View on GitHub →
JavaScript93.4%
PostScript5.9%
TypeScript0.6%
Rich Text Format0.1%

Commit activity

Last 12 weeks · 3 commits

Full graph →

Community health

5 of 6 standards met

Community profile →
100
✓README✓License✓Contributing✓Code of Conduct○Issue Template✓PR Template

Recent fixes

View closed PRs →
MaximeDametis
False positive: text file with UTF-16 LE BOM (FF FE) detected as audio/mpegClosedIssue

Description When passing an empty file that only contains a UTF-16 Little Endian BOM (FF FE), file-type incorrectly identifies it as an audio/mpeg .mp1 file. This issue occurs not only with empty files but also with fully populated UTF-16 LE text files (like valid .csv files). The presence of text data after the BOM does not prevent the false positive, making it impossible to rely on file-type when handling UTF-16 text files. ew.csv empty.csv Existing Issue Check [x] I have searched the existing issues and could not find any related to my problem. ESM (ECMAScript Module) Requirement Acknowledgment [x] My project is an ESM project and my contains the following entry: . File-Type Scope Acknowledgment [x] I understand that file-type detects binary file types and not text or other formats.

MaximeDametis · 1w ago
cornzz
Support for iWork files (.pages, .numbers, .key)ClosedIssue

Description Common file types from the macOS-native Pages, Numbers and Keynote apps. Similar to Microsoft Office documents, these are zip files and can be detected by the file, which contains snappy-compressed protobuf messages. Keynote files can also be recognized by the contained and files, while for Pages and Numbers files probably the file has to be decompressed and parsed. Currently I have no time for this, for anyone else wanting to tackle this, here is some more information: I found this tool quite helpful https://sheetjs.com/tools/iwa-inspector/, its source code for decoding .iwa files can be found here. Also, this description of IWA files (especially "Determining File Type" at the bottom), as well as this one. Lastly, the Apache Tika toolkit also uses this method to detect iWork files (source), however they also have not implemented proper support for numbers and pages files yet: https://issues.apache.org/jira/browse/TIKA-4464 Existing Issue Check [x] I have searched the existing issues and could not find any related to my problem. File-Type Scope Acknowledgment [x] I understand that file-type detects binary file types and not text or other formats.

cornzz · 5mo ago
bischofmax
docx, pptx, xlsx files saved with libre office are detected as application/zipClosedIssue

Description I saw that this was already an issue in 2020. But since version 21.1.0 I am seeing the behavior explained underneath. Version 21.0.0 still had the expected behavior. Current behavior docx, pptx, xlsx files saved with microsoft word are correctly detected as: application/vnd.openxmlformats-officedocument.wordprocessingml.document application/vnd.openxmlformats-officedocument.presentationml.presentation application/vnd.openxmlformats-officedocument.spreadsheetml.sheet docx, pptx, xlsx files saved with libre office are detected as application/zip. Expected behavior docx, pptx, xlsx files saved with libre office are detected as: application/vnd.openxmlformats-officedocument.wordprocessingml.document application/vnd.openxmlformats, officedocument.presentationml.presentation application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Existing Issue Check [x] I have searched the existing issues and could not find any related to my problem. ESM (ECMAScript Module) Requirement Acknowledgment [x] My project is an ESM project and my contains the following entry: . File-Type Scope Acknowledgment [x] I understand that file-type detects binary file types and not text or other formats.

bischofmax · 5mo ago
Structured data for AI agents

Repository: sindresorhus/file-type. Description: Detect the file type of a file, stream, or data Stars: 4321, Forks: 394. Primary language: JavaScript. Languages: JavaScript (93.4%), PostScript (5.9%), TypeScript (0.6%), Rich Text Format (0.1%). License: MIT. Topics: buffer, detect, file, file-types, javascript, magic, magic-numbers, nodejs, uint8array. Latest release: v22.0.2 (1w ago). Open PRs: 0, open issues: 0. Last activity: 1w ago. Community health: 100%. Top contributors: sindresorhus, Borewit, kevva, mifi, karlhiramoto, sly7-7, stroncium, mceachen, junmer, Richienb and others.

·@ofershap

Replace github.com with gitshow.dev