mmmagic-type Detect file type with mmmagic and mime. Install npm i mmmagic-type Usage import fs from 'fs' import { detect } from 'mmmagic-type' detect(fs.readFileSync('/path/to/file')).then(type => { console.log(type) // { ext: '', mime: '' } })