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 stars395 forks119 contributorsQuiet · 2mo agoSince 2014v22.0.1MIT

Meet the team

See all 119 on GitHub →
sindresorhus
sindresorhus301 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.3%
PostScript6%
TypeScript0.6%
Rich Text Format0.1%

Recent fixes

View closed PRs →
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 · 3mo 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 · 3mo ago
Borewit
Normalize MIME-types we invented with `/x-ft-` prefixMergedPR

MIME media subtypes prefixed with are custom-defined by us. They are neither formally registered with IANA nor based on any informal conventions. These MIME-type mappings changed: ↦ (based on https://datatracker.ietf.org/doc/draft-diaz-lzip/) ↦ ↦ ↦ ↦

Borewit · 3mo ago
Structured data for AI agents

Repository: sindresorhus/file-type. Description: Detect the file type of a file, stream, or data Stars: 4305, Forks: 395. Primary language: JavaScript. Languages: JavaScript (93.3%), PostScript (6%), 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.1 (2mo ago). Open PRs: 0, open issues: 0. Last activity: 2mo ago. Top contributors: sindresorhus, Borewit, kevva, mifi, karlhiramoto, sly7-7, stroncium, mceachen, junmer, Richienb and others.

·@ofershap

Replace github.com with gitshow.dev