Try it
Usage
import { mp3ToWav } from './src/index.js';
const input = document.querySelector('input[type=file]');
input.addEventListener('change', async () => {
const { blob, sampleRate, duration } = await mp3ToWav(input.files[0], {
sampleRate: 'original', // or 44100, 48000, 16000…
bitDepth: 16, // 16 | 24 | 32 (float)
mono: false,
});
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'converted.wav';
link.click();
});
How it works
1. Detect the rate
It reads the first MPEG frame header to find the MP3's real sample rate, skipping ID3 tags.
2. Decode locally
decodeAudioData runs on an OfflineAudioContext created at that rate, so nothing gets resampled to 48 kHz by accident.
3. Write the WAV
A small RIFF/WAVE encoder writes PCM (16/24-bit) or IEEE float (32-bit) and returns a Blob.
Need a ready-made app? This library powers MP3 to WAV Convert, a free, private online converter with batch ZIP downloads, one-click presets and guides in four languages.