WAV header format

Byte-by-byte layout of the 44-byte WAV header, how the fields relate, and why real files often differ.

The 44-byte header

A PCM WAV file that holds only the required chunks has a 44-byte header: 12 bytes of RIFF header, a 24-byte fmt chunk and the 8-byte header of the data chunk. Sample data starts at byte 44. Every number is little-endian. The right-hand column shows the values in the sample WAV, an 8 kHz mono 16-bit tone that is 4044 bytes long.

OffsetBytesFieldSample WAV
04Chunk IDRIFF
44RIFF size (file size minus 8)4036
84Form typeWAVE
124Chunk ID, with a trailing spacefmt
164fmt chunk size16
202Audio format (1 is PCM)1
222Channels1
244Sample rate8000
284Byte rate16000
322Block align2
342Bits per sample16
364Chunk IDdata
404data chunk size4000
44restSample data2000 frames

How the fields relate

Block align is the size of one sample frame: channels times bits per sample divided by 8. Byte rate is sample rate times block align. Divide the data size by block align to get the frame count, and the frame count by the sample rate to get the duration. In the sample, 4000 / 2 = 2000 frames, and 2000 / 8000 = 0.25 seconds.

PCM samples of 8 bits are unsigned, so silence is 128. Samples of 16 bits and wider are signed, so silence is 0. With more than one channel, samples are interleaved: left, right, left, right.

Why many WAV headers are not 44 bytes

Real files often carry more chunks: LIST with INFO tags, bext from broadcast tools, fact, cue , smpl, id3 , and JUNK padding that reserves room for the header to grow. They can sit before or after data. A fmt chunk in the extensible format is 40 bytes instead of 16, which also moves data.

Code that jumps straight to byte 44 will read metadata as audio. The safe method is to walk the chunks: read the ID and size, skip that many bytes plus one pad byte when the size is odd, and repeat until you reach data. The RIFF Viewer does that walk and shows every chunk it finds.

ID4 bytes0Size4 bytes4Datasize bytes8Pad1 if size odd8 + size
One chunk. The size counts only the data, not the 8-byte header or the pad byte.

The 4 GB limit

Sizes are unsigned 32-bit numbers, so a RIFF file cannot describe more than 4,294,967,295 bytes. RF64 (EBU Tech 3306) and BW64 (ITU-R BS.2088) get around this by replacing RIFF with RF64 or BW64 and storing 64-bit sizes in a ds64 chunk. This viewer does not parse those files; it reports that the file does not start with a RIFF header.

Check a header with the viewer

Load your file, then select fmt . In the hex view, offsets count from the start of the selected chunk, so the first payload byte is at 0x08, after the 4-byte ID and the 4-byte size. The audio format is at 0x08, channels at 0x0A, sample rate at 0x0C, byte rate at 0x10, block align at 0x14 and bits per sample at 0x16. A sample rate of 8000 is stored as 40 1f 00 00.

RIFF Viewer showing tone.wav: a RIFF WAVE chunk holding fmt (16 bytes) and data (4,000 bytes), with fmt selected and its sample rate bytes highlighted in the hex view.
The sample WAV in the viewer with fmt selected. The sample rate sits at 0x0C: 40 1F 00 00, which is 8000.

Questions

How big is a WAV header?

44 bytes for a plain PCM file with only the fmt and data chunks. Files with metadata or an extensible fmt chunk have longer headers, so read the chunks instead of assuming 44.

Is a WAV header little-endian?

Yes. All RIFF numbers are little-endian. A big-endian variant with the ID RIFX exists but is rare, and this viewer does not parse it.

How do I work out the duration from the header?

Divide the data chunk size by the byte rate. For the sample WAV, 4000 / 16000 = 0.25 seconds.

What should the RIFF chunk size be?

The file size minus 8. If it is 0 or much smaller, the recording was probably interrupted before the header was finished.

Open the RIFF Viewer with your own file, or download the sample used above.