audio-type [](https://github.com/audiojs/audio-type/actions/workflows/test.js.yml) [](http://github.com/badges/stability-badges) [](https://www.npmjs.com/package/audio-type) [](https://www.npmjs.com/package/audio-type)
March 14, 2026 · View on GitHub
Detect the audio type of a ArrayBuffer/Uint8Array
Install
$ npm i audio-type
Usage
Node.js
import readChunk from 'read-chunk'; // npm install read-chunk
import audioType from 'audio-type';
var buffer = readChunk.sync('meow.wav', 0, 64);
audioType(buffer);
//=> wav
Browser
import audioType from './audio-type.js'
var xhr = new XMLHttpRequest();
xhr.open('GET', 'meow.flac');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
audioType(this.response);
//=> flac
};
xhr.send();
API
audioType(buffer)
Returns: 'wav', 'aiff', 'mp3', 'aac', 'flac', 'm4a', 'opus', 'oga', 'qoa', 'mid', 'caf', 'wma', 'amr', 'webm'
buffer
Type: buffer (Node.js), arrayBuffer, uint8array
It only needs the first 64 bytes.
License
MIT • ॐ