FLAC file format
Free Lossless Audio Codec, a lossless compressed audio format.
- MIME type
- audio/flac
- Extensions
- .flac
- Category
- Audio
Magic-number signature
| 0x00000000 | 664C6143 | fLaC | 'fLaC' stream marker |
About the FLAC format
FLAC compresses audio without discarding anything, typically to between half and seventy percent of the original size, and decoding it returns the exact samples that went in. It works by fitting a short predictor to each block of audio and storing only the residual, which is cheap to reverse and needs no floating-point arithmetic at all — a decoder is fast enough for the weakest hardware. The file is a four-byte marker, then a chain of metadata blocks, then the audio frames. The first metadata block is always STREAMINFO and it holds everything a player needs to set up before a single sample is decoded, including an MD5 digest of the original audio that makes it possible to prove a decode was bit-perfect years after the fact.
Header layout, byte by byte
| Offset | Length | Field | Meaning |
|---|---|---|---|
| 0 | 4 | Stream marker | 66 4C 61 43, the ASCII letters fLaC with that exact mixed case. It is the entire magic number and, unlike most audio formats, it is genuinely at offset 0 — the FLAC specification does not allow a metadata tag to be written in front of it. |
| 4 | 1 | First metadata block header | The top bit is the last-metadata-block flag and the low seven bits are the block type. This byte can only be 00 or 80, because the specification requires the first block to be STREAMINFO, which is type 0; 80 would mean a file with no other metadata at all. |
| 5 | 3 | STREAMINFO length | A big-endian 24-bit byte count of the block that follows, and always 00 00 22 — 34 bytes. Every other metadata block has a variable length here; this one does not, which makes it a useful sanity check on a suspect file. |
| 8 | 2 | Minimum block size | The smallest number of samples in any frame, big-endian, and at least 16. When it equals the maximum below, every frame is the same length and a seek can be computed arithmetically rather than looked up. |
| 10 | 2 | Maximum block size | The largest number of samples in any frame, big-endian, up to 65535. The reference encoder uses 4096 for most rates, which reads 10 00; a file holding 12 00 instead is using 4608. |
| 12 | 3 | Minimum frame size | A big-endian 24-bit byte count of the smallest frame in the stream. Zero is legal and means the encoder did not record it, which is what a streaming writer that never came back to patch the header leaves behind. |
| 15 | 3 | Maximum frame size | The largest frame in the stream, in bytes, encoded the same way, and zero when unknown. A decoder uses the pair to size its input buffer without guessing. |
| 18 | 8 | Packed audio parameters | Sixty-four bits that do not respect byte boundaries at all: twenty bits of sample rate in Hz, then three bits holding the channel count minus one, then five bits holding the bits per sample minus one, then a 36-bit total sample count. The rate 0A C4 4 is 44100; a rate of zero is illegal, and a total sample count of zero means the length was not known when the file was written. |
| 26 | 16 | MD5 of the unencoded audio | The digest of the raw samples before compression. This is what a verify pass compares against after decoding, and it is the reason FLAC can prove a rip is bit-identical to the disc rather than merely playable. All-zero means the encoder declined to compute it, and every guarantee built on it is then gone. |
| 42 | 4 | Second metadata block header | The same one-byte flag-and-type followed by a 24-bit length, at a fixed offset because STREAMINFO is always exactly 34 bytes. Types are 0 STREAMINFO, 1 PADDING, 2 APPLICATION, 3 SEEKTABLE, 4 VORBIS_COMMENT, 5 CUESHEET and 6 PICTURE. A header reading 04 00 00 2E is therefore a Vorbis comment of 46 bytes with the last-block flag clear, so at least one more block follows it. |
Telling it apart from its neighbours
| Easily confused with | How to tell |
|---|---|
| Ogg | FLAC can be carried inside an Ogg container as well as natively, and a .oga or .ogg file holding it begins with the Ogg page marker 4F 67 67 53, the letters OggS, at offset 0. The string fLaC still appears, a few dozen bytes in, inside the first packet — so a detector scanning for the marker rather than testing offset 0 will call an Ogg file a native FLAC. |
| WAV | The pair people actually compare, since both are lossless and hold the same samples. WAV is RIFF, starting 52 49 46 46 with the form type WAVE at offset 8, stores PCM uncompressed and has a 32-bit size field that caps a file at 4 GB. FLAC stores the same audio in roughly half the space, adds proper tagging, and carries the MD5 that lets you verify it later. |
| MP3 | Nothing subtle at byte level — readable fLaC against an ID3 tag or a frame sync — but there is a real failure mode in one direction. Some tagging software writes an ID3v2 tag onto the front of a FLAC file even though the specification forbids it, which pushes the marker off offset 0 and makes the file look like an MP3 to anything that tests for 49 44 33 first. |
| ALAC | Apple's lossless codec, and the reason a lossless library can arrive in either form. ALAC lives inside an MP4 container, so the file begins with the ftyp box at offset 4 and usually carries the .m4a extension; there is no fLaC marker anywhere in it. Converting between the two is a genuine re-encode of the same samples with no quality change, since both are lossless. |
How these files break
- Truncation. A cut-off FLAC decodes cleanly right up to the missing bytes and simply ends, so playback proves nothing. What catches it is the MD5 at offset 26: a full verify decodes every sample and compares the digest, which is the only way to know that a file from an old backup is still what it was.
- An all-zero MD5. Some encoders and most streaming writers skip computing the digest, leaving sixteen zero bytes at offset 26. The audio is perfectly good and the file is valid, and every integrity guarantee people believe FLAC gives them is quietly absent — a verify pass on such a file can only confirm the frame checksums, not the content.
- A total sample count of zero. The 36-bit field inside the packed parameters at offset 18 is patched in when encoding finishes, so anything written to a pipe or interrupted leaves it at zero. The file plays fine and reports no duration, and players either show a blank time or scan the whole file to work it out.
- A byte flipped inside a frame. Each frame carries its own CRC-16, so a decoder detects the damage and either drops the frame or emits a click, while the rest of the stream continues untouched. This is why a slightly damaged FLAC still plays end to end, and why the failure shows up as one audible artefact rather than a refusal to open.
- An ID3v2 tag prepended by a careless tagger. The specification requires fLaC at offset 0 and some software writes an ID3 header in front of it anyway. Strict decoders reject the file outright, tolerant ones scan forward and play it, and detectors identify it as an MP3 — from a file whose audio is entirely intact.
Where the format stands today
FLAC is what lossless audio means in practice everywhere outside Apple's ecosystem. CD rips, high-resolution downloads from Bandcamp and Qobuz, archival masters and anything destined to be transcoded later all live in it, because it is free of patents, free of licensing, fast to decode on hardware that cannot manage much, and supported by every browser since around 2016. Its only serious competitor is ALAC, which does the same job with the same results inside an MP4 container and exists mainly because Apple wanted its own; WavPack and Monkey's Audio have small followings and no reach. FLAC does not compete with MP3, AAC or Opus at all — it is two to five times their size and is not meant for delivery. The pattern that makes sense is to keep FLAC as the master and generate a lossy copy whenever one is needed, because the lossy copy can always be made again and the detail thrown away to produce it never comes back.
Open FLAC 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 FLAC — compare their leading bytes.