DEV Community

Michael Lip
Michael Lip

Posted on • Originally published at zovo.one

Audio Formats Explained: When to Use MP3, WAV, FLAC, OGG, and AAC

A coworker sent me a .flac file last week and asked me to add it to a web project. My first reaction was "just convert it to MP3." But then I stopped and thought about it. Why MP3? Is it actually the best format for web audio in 2026? The answer, like most things in engineering, is "it depends." And the reasoning matters more than the answer.

Audio formats are a tradeoff between file size, quality, compatibility, and licensing. Choosing the wrong format means either wasting bandwidth, losing quality, or breaking playback on certain devices. Here's what each format actually is and when to use it.

Lossy vs lossless: the fundamental split

Audio compression falls into two categories.

Lossy compression permanently removes audio data that the algorithm determines is inaudible or less important. You get smaller files, but the removed data is gone forever. Re-encoding a lossy file makes it worse -- each generation loses more data. MP3, AAC, OGG Vorbis, and Opus are lossy formats.

Lossless compression reduces file size without losing any data. The decompressed audio is bit-for-bit identical to the original. Think of it like ZIP for audio. FLAC, ALAC (Apple Lossless), and WAV (uncompressed, technically not compressed at all) are lossless formats.

The distinction matters because you should always start from a lossless source and convert to lossy as the final step. Going from lossy to lossy (MP3 to AAC, for example) degrades quality twice. Going from lossy to lossless (MP3 to FLAC) wastes space because you can't recover data that was already removed.

The formats

WAV (Waveform Audio File Format). Uncompressed PCM audio. A 3-minute song at CD quality (44.1 kHz, 16-bit, stereo) is about 30 MB. No quality loss, no encoding/decoding overhead, massive file size. Used in professional audio production where every sample matters. Not for web delivery.

MP3 (MPEG-1 Audio Layer III). The format that changed everything. At 128 kbps, a 3-minute song is about 3 MB -- one-tenth the size of WAV. At 320 kbps (the maximum), it's about 7 MB. MP3 is universally supported but technically inferior to modern codecs. The patents expired in 2017, so it's now free to use everywhere.

The quality hierarchy for MP3: 128 kbps is acceptable for speech. 192 kbps is decent for music. 256 kbps is good. 320 kbps is the ceiling and is functionally transparent (indistinguishable from the original) for most people on most equipment.

AAC (Advanced Audio Coding). Apple's preferred format. Technically superior to MP3 -- it achieves better quality at the same bitrate, especially at lower bitrates. A 128 kbps AAC file sounds roughly equivalent to a 160 kbps MP3. AAC is the default format for iTunes, YouTube, and most streaming services. Supported by all major browsers.

OGG Vorbis. An open-source lossy format developed by the Xiph.Org Foundation. Quality is comparable to AAC. No licensing fees or patent issues. The main limitation is compatibility -- Apple devices have historically been slow to support it. All major browsers support it now.

Opus. The newer codec from Xiph.Org, designed for both speech and music. It's objectively the best lossy audio codec available today. At 128 kbps, Opus sounds better than both MP3 at 320 kbps and AAC at 256 kbps in blind listening tests. It handles variable bitrate beautifully and works across a wide range of bitrates (6 kbps to 510 kbps). Used by Discord, WhatsApp, and most WebRTC implementations. Browser support is excellent.

FLAC (Free Lossless Audio Codec). Open-source lossless compression. Reduces file size by 50-60% compared to WAV with zero quality loss. A 30 MB WAV becomes a 12-15 MB FLAC. Used for archival storage and by audiophiles who refuse lossy compression. Not supported by Safari without a container format workaround, which limits its use on the web.

What to use and when

For web audio (music, podcasts, sound effects): Use Opus if your target browsers support it (they almost certainly do). Fall back to AAC for maximum compatibility. MP3 is fine as a universal fallback.

<audio controls>
  <source src="audio.opus" type="audio/opus">
  <source src="audio.aac" type="audio/aac">
  <source src="audio.mp3" type="audio/mpeg">
</audio>
Enter fullscreen mode Exit fullscreen mode

The browser picks the first format it supports. Opus is tried first because it's the smallest file at the best quality.

For archival storage: FLAC. Always. It's lossless, open-source, and widely supported by media players. Store your master copies as FLAC and convert to lossy formats for distribution.

For professional audio production: WAV or AIFF. Uncompressed formats with no encoding artifacts. DAWs (Digital Audio Workstations) work natively with these formats.

For voice recordings and speech: Opus at 32-64 kbps. Opus was specifically designed for speech at low bitrates. A 1-hour podcast at 48 kbps Opus is about 21 MB with excellent voice clarity.

Converting with FFmpeg

FFmpeg is the Swiss Army knife of audio/video conversion. Every format conversion you'll ever need can be done in one command:

# WAV to MP3 (320 kbps)
ffmpeg -i input.wav -b:a 320k output.mp3

# WAV to AAC (256 kbps)
ffmpeg -i input.wav -c:a aac -b:a 256k output.m4a

# WAV to Opus (128 kbps)
ffmpeg -i input.wav -c:a libopus -b:a 128k output.opus

# WAV to FLAC
ffmpeg -i input.wav -c:a flac output.flac

# MP3 to WAV (for further processing, not quality improvement)
ffmpeg -i input.mp3 output.wav
Enter fullscreen mode Exit fullscreen mode

The -b:a flag sets the audio bitrate. The -c:a flag specifies the audio codec.

Mistakes to avoid

Converting between lossy formats unnecessarily. Every lossy-to-lossy conversion degrades quality. If you need to change from MP3 to AAC, go back to the original lossless source if possible.

Using WAV for web delivery. An uncompressed audio file is 10x larger than necessary. Your users don't have unlimited bandwidth.

Using MP3 at low bitrates when Opus exists. MP3 at 64 kbps sounds terrible. Opus at 64 kbps sounds genuinely good. If you're constrained on file size, Opus gives you dramatically better quality per kilobyte.

Assuming higher bitrate always means better quality. Above a certain threshold (around 256 kbps for MP3, 192 kbps for AAC, 128 kbps for Opus), most people cannot distinguish the encoded audio from the original in a blind test. Going higher wastes bandwidth without audible benefit.

For quick conversions without installing FFmpeg or remembering command-line flags, I built an audio converter at zovo.one/free-tools/audio-converter that handles the common format conversions in the browser. Drag in a file, pick your target format and quality, get the converted output.

Understanding audio formats isn't just about knowing which file extension to use. It's about understanding the tradeoffs so you can make informed decisions about quality, size, and compatibility for your specific use case.


I'm Michael Lip. I build free developer tools at zovo.one. 350+ tools, all private, all free.

Top comments (0)