WAV file format
Waveform Audio, an uncompressed (typically PCM) RIFF audio container.
- MIME type
- audio/wav
- Extensions
- .wav
- Category
- Audio
Magic-number signature
| 0x00000000 | 52494646 | RIFF | RIFF container |
| 0x00000008 | 57415645 | WAVE | 'WAVE' form type |
About the WAV format
WAV stores audio as raw PCM samples inside a RIFF container, giving lossless quality and simple editing at the cost of large files — the standard for recording and production. The header is 'RIFF', a length, then the form type 'WAVE'. Everything after those first four bytes is little-endian, and the file is a flat list of chunks: a four-byte chunk id, a four-byte size, then that many bytes of payload, padded to an even length. That layout is why WAV is trivial to write and trivial to get subtly wrong: nothing in the file cross-checks anything else, so a size field that disagrees with reality is a perfectly well-formed WAV that no player handles the same way.
Header layout, byte by byte
| Offset | Length | Field | Meaning |
|---|---|---|---|
| 0 | 4 | RIFF chunk id | The ASCII letters RIFF, 52 49 46 46. RIFF is Microsoft and IBM's generic Resource Interchange File Format, so this is not a WAV marker at all — AVI and WebP open with exactly the same four bytes. |
| 4 | 4 | RIFF chunk size | Little-endian unsigned 32-bit count of everything that follows, so the file length minus eight. A 176478-byte recording carries 56 B1 02 00 here, which is 176470. Nothing enforces it, and a wrong value is the single most common defect in hand-written WAV files. |
| 8 | 4 | WAVE form type | 57 41 56 45. This is the field that actually says audio: an AVI has 'AVI ' here and a WebP has 'WEBP'. A detector that stops after checking RIFF at offset 0 cannot tell those three apart. |
| 12 | 4 | 'fmt ' chunk id | 66 6D 74 20 — note the trailing space, because every RIFF chunk id is exactly four bytes and 'fmt' is only three. The format chunk is required and by convention comes first. |
| 16 | 4 | fmt chunk size | 16 for plain PCM, 18 when a two-byte extension size is appended, and 40 for WAVE_FORMAT_EXTENSIBLE. Anything other than 16 pushes every later chunk further down the file, which is why offset 36 is not a reliable landmark. |
| 20 | 2 | Audio format code | 1 is uncompressed PCM, 3 is 32-bit IEEE float, 6 is A-law, 7 is mu-law, and FE FF (65534) is WAVE_FORMAT_EXTENSIBLE, where the real codec is named by a GUID inside the format extension instead. |
| 22 | 2 | Channel count | 1 for mono, 2 for stereo, more for surround layouts. With extensible format a channel mask states which speaker each channel belongs to; a plain PCM WAV does not say, so channel order is convention only. |
| 24 | 4 | Sample rate | Frames per second, little-endian. 44100 appears as 44 AC 00 00 and 48000 as 80 BB 00 00. This is the only field a player uses to decide playback speed. |
| 28 | 4 | Byte rate | Sample rate times channels times bits per sample divided by eight — 176400 for 44.1 kHz stereo 16-bit. It is fully derivable from the three fields around it, which makes it a free consistency check on a suspect header. |
| 32 | 2 | Block align | Bytes per sample frame: channels times bits per sample divided by eight, so 4 for 16-bit stereo. Seeking arithmetic uses it, so a wrong value turns every seek into a burst of noise. |
| 34 | 2 | Bits per sample | 8, 16, 24 or 32. Eight-bit PCM is unsigned and everything wider is signed two's complement, a discontinuity that catches out anyone writing a converter from scratch. |
| 36 | 4 | Next chunk id | Only in the minimal case is this the 'data' chunk. Encoders routinely put a 'LIST' INFO block or a 'fact' chunk first — a file written by one common encoder has 4C 49 53 54 here — so a parser must walk the chunk list rather than assume an offset. |
| variable | 4 | 'data' chunk size | The four bytes immediately after the 64 61 74 61 chunk id, giving the number of sample bytes that follow. Being unsigned 32-bit, it is the origin of WAV's hard four-gigabyte ceiling. |
Telling it apart from its neighbours
| Easily confused with | How to tell |
|---|---|
| AVI | Identical for the first eight bytes: both are RIFF containers with a little-endian length at offset 4. The form type at offset 8 decides it — 57 41 56 45 for audio, 41 56 49 20 ('AVI ' with a trailing space) for video. This is the same trap that makes a naive 'starts with RIFF' check report video files as audio. |
| WebP | The third member of the RIFF family, with 57 45 42 50 at offset 8. So three completely unrelated media types share the same first eight bytes and differ only in one four-byte word, which is why any honest RIFF detector reads twelve bytes rather than four. |
| RF64 / BW64 | Recordings over four gigabytes cannot express their length in a 32-bit field, so the broadcast variants replace the id at offset 0 with 52 46 36 34 ('RF64') or 42 57 36 34 ('BW64'), set the size at offset 4 to FF FF FF FF, and add a 'ds64' chunk holding real 64-bit sizes. The rest of the file is an ordinary WAVE, which is why some players open them and others see a broken header. |
| FLAC | Both are lossless, and people compare them constantly, but there is no ambiguity in the bytes: a native FLAC begins 66 4C 61 43 ('fLaC') followed by a 34-byte STREAMINFO block. A FLAC file renamed to .wav will not open anywhere, because no WAV reader scans for a form type. |
| MP3 | MP3 has no container at all. It begins either with an 'ID3' tag or directly with a frame sync — eleven set bits, so FF followed by a byte whose top three bits are set. Nothing about it resembles RIFF, and a .wav that starts FF FB is a mislabelled MP3. |
How these files break
- A crashed or force-quit recorder. The audio data is on disk but the two size fields — the RIFF size at offset 4 and the data chunk size — still hold whatever was written when recording started, often zero or a pre-allocated length. Players then stop early, or read past the samples into whatever follows. The repair is arithmetic: recompute both fields from the real file length and the file plays perfectly.
- The four-gigabyte ceiling. Both size fields are unsigned 32-bit, so a long multitrack or field recording silently wraps and the header describes a file far smaller than the one on disk. RF64, BW64 and Sony's Wave64 all exist purely to escape this, and none of them is plain WAV.
- Bit depth that disagrees with the samples. If offset 34 says 16 but the samples were written 24-bit, every frame boundary is wrong and the file plays as rhythmic static at roughly the right duration. The header is valid; it is simply describing different bytes than the ones present.
- Missing chunk padding. RIFF requires odd-length chunks to be followed by a pad byte that is not counted in the chunk size. A writer that forgets it leaves every later chunk offset one byte low, so a reader lands mid-chunk and reports garbage chunk ids like 'ata\0'.
- Prepended bytes. An HTML error page, a stray UTF-8 BOM or an email header saved ahead of the audio pushes RIFF off offset 0. Every sample survives; deleting everything before 52 49 46 46 restores the file exactly.
Where the format stands today
WAV is still the working format of audio production, and that is unlikely to change: it is lossless, every DAW and every operating system reads it, and the layout is simple enough that writing one from scratch takes a page of code. What it is not is a distribution format — an hour of CD-quality stereo is about 600 MB, so anything that leaves a studio gets encoded to AAC, Opus or MP3 first, and FLAC has taken over lossless distribution because it stores the same samples in roughly half the space with a real metadata model. WAV also remains the default for short system sounds, sample libraries, speech corpora and anything a microcontroller or a game engine has to play without a decoder, because raw PCM needs no CPU at all. Its two real limits are the four-gigabyte ceiling and the absence of a standard metadata scheme, and both are why broadcast work moved to RF64 and BWF.
Open WAV files on this site
Every one of these runs in your browser — the file never leaves your machine.
Related formats
Formats that are easy to confuse with WAV — compare their leading bytes.