npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

audio-decode

v3.10.1

Published

Decode audio data in node or browser

Downloads

1,237,289

Readme

audio-decode test

Decode any audio format to raw samples. JS / WASM – no ffmpeg, no native bindings, works in both node and browser. Small API, minimal size, near-native performance, lazy-loading, chunked decoding.

npm install audio-decode

import decode from 'audio-decode';

const { channelData, sampleRate } = await decode(anyAudioBuffer);

Supported formats

| Format | Package | Size | Engine | |--------|---------|------|--------| | MP3 | @audio/decode-mp3 | 92 KB | WASM | | WAV | @audio/decode-wav | 4 KB | JS | | OGG Vorbis | @audio/decode-vorbis | 164 KB | WASM | | FLAC | @audio/decode-flac | 133 KB | WASM | | Opus | @audio/decode-opus | 178 KB | WASM | | M4A / AAC | @audio/decode-aac | 368 KB | WASM | | QOA | @audio/decode-qoa | 8 KB | JS | | AIFF | @audio/decode-aiff | 20 KB | JS | | CAF | @audio/decode-caf | 7 KB | JS | | WebM | @audio/decode-webm | 263 KB | WASM | | AMR | @audio/decode-amr | 241 KB | WASM | | WMA | @audio/decode-wma | 91 KB | WASM |

Whole-file

Auto-detects format. Input can be ArrayBuffer, Uint8Array, or Buffer.

import decode from 'audio-decode'

let { channelData, sampleRate } = await decode(buf)

Chunked

let dec = await decode.mp3()
let a = await dec(chunk1)    // { channelData, sampleRate }
let b = await dec(chunk2)
await dec()                  // close

Streaming

import decode from 'audio-decode'

for await (let { channelData, sampleRate } of decode.mp3(response.body)) {
  // process chunks
}

Works with ReadableStream, fetch body, Node stream, or any async iterable.

Formats: mp3, flac, opus, oga, m4a, wav, qoa, aac, aiff, caf, webm, amr, wma.

Browser

Each codec is a self-contained bundle under @audio/* — no transitive deps, no import map bloat. For selective loading in the browser (avoids bundling all codecs):

<script type="importmap">
{
  "imports": {
    "audio-decode": "https://esm.sh/audio-decode",
    "audio-type": "https://esm.sh/audio-type",
    "@audio/decode-mp3": "https://esm.sh/@audio/decode-mp3",
    "@audio/decode-wav": "https://esm.sh/@audio/decode-wav",
    "@audio/decode-flac": "https://esm.sh/@audio/decode-flac",
    "@audio/decode-opus": "https://esm.sh/@audio/decode-opus",
    "@audio/decode-vorbis": "https://esm.sh/@audio/decode-vorbis",
    "@audio/decode-aac": "https://esm.sh/@audio/decode-aac",
    "@audio/decode-qoa": "https://esm.sh/@audio/decode-qoa",
    "@audio/decode-aiff": "https://esm.sh/@audio/decode-aiff",
    "@audio/decode-caf": "https://esm.sh/@audio/decode-caf",
    "@audio/decode-webm": "https://esm.sh/@audio/decode-webm",
    "@audio/decode-amr": "https://esm.sh/@audio/decode-amr",
    "@audio/decode-wma": "https://esm.sh/@audio/decode-wma"
  }
}
</script>
<script type="module">
  import decode from 'audio-decode'
  let { channelData, sampleRate } = await decode(buf)
</script>

Only list the codecs you need — each @audio/decode-* package bundles all its WASM/JS deps internally.

Metadata

Read tags, pictures, markers and regions without decoding samples. Available for wav, mp3, flac.

import { wav, mp3, flac } from 'audio-decode/meta'

let { meta, sampleRate, markers, regions } = mp3(bytes)
// meta: { title, artist, album, year, bpm, key, comment, pictures, raw, ... }
// markers: [{ sample, label }]
// regions: [{ sample, length, label }]

Each codec sub-package also exposes its parser directly:

import { parseMeta } from '@audio/decode-wav/meta'
let info = parseMeta(wavBytes)

WebWorker

Each @audio/decode-* package is a self-contained ESM module — import directly in a worker:

// decode-worker.js
import decode from '@audio/decode-mp3'

self.onmessage = async ({ data }) => {
  let pcm = await decode(data)
  self.postMessage(pcm, pcm.channelData.map(ch => ch.buffer))
}

// main.js
let worker = new Worker('./decode-worker.js', { type: 'module' })
worker.postMessage(mp3buf, [mp3buf])
worker.onmessage = ({ data }) => { /* { channelData, sampleRate } */ }

See also