← All repos

file-type

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

bufferdetectfilefile-typesjavascriptmagicmagic-numbersnodejsuint8array
Browse cluster: Terminal & CLI Output Styling
640commits
120contributors
4languages

Tech stack & purpose

The file-type package is a JavaScript library that detects binary file formats by examining magic numbers—the distinctive byte signatures at the beginning of files. It works with files, streams, and data buffers in Node.js and browser environments, supporting detection of numerous modern binary formats like PNG, JPEG, MP3, and many others. The package is built as an ESM module for JavaScript and TypeScript and provides multiple detection methods including `fileTypeFromFile()`, `fileTypeFromBuffer()`, `fileTypeFromStream()`, and `fileTypeFromBlob()`, along with support for custom detectors and tokenizer-based approaches for advanced use cases like HTTP range requests and Amazon S3 access.

Community & reference links

Languages

JavaScript
93.3%
PostScript
6.0%
TypeScript
0.6%
Rich Text Format
0.1%

Contributors (top 30 of 120)