.FLAC Free Lossless Audio Codec
.flac

Free Lossless Audio Codec

Convert FLAC audio to MP3, WAV, or OGG directly in your browser — no upload, no server, no quality compromise. FLAC, standardized as RFC 9639 in 2024, compresses audio to 50-70% of WAV size while preserving bit-perfect integrity verified by an MD5 hash embedded in every file's STREAMINFO block. FileDex uses FFmpeg WebAssembly to decode your lossless FLAC locally and encode to your chosen format with full bitrate control.

Learn more ↓
Audio structure
fLaC stream marker
META STREAMINFO · tags
FRAME encoded blocks
LosslessAudio2001
By FileDex

Your files never leave your device

Common questions

Is FLAC really lossless — does it sound identical to WAV?

Yes. FLAC decodes to bit-identical PCM as the original WAV. This is mathematically provable — the STREAMINFO block stores an MD5 hash of the uncompressed audio, and running flac --test verifies the roundtrip. FLAC reduces file size by 30-50% using prediction and entropy coding, not by discarding audio data.

Does converting FLAC to MP3 lose quality?

Yes. MP3 is a lossy format that discards audio data using psychoacoustic modeling. At 192+ kbps VBR (LAME -V 2), the quality loss is inaudible to most listeners in controlled tests. Encoding from FLAC produces the best possible MP3 since the source is lossless.

Can I play FLAC files on my iPhone?

Yes, since iOS 11. The Files app plays FLAC natively, and third-party players like VLC support FLAC. Apple Music does not stream in FLAC (it uses ALAC for lossless), but you can import FLAC files into your library.

Which is better for archiving: FLAC or WAV?

FLAC. Both preserve identical audio quality, but FLAC is 30-50% smaller. FLAC also embeds Vorbis Comment metadata (artist, album, track number) and album art directly in the file, while WAV metadata support is limited and inconsistent across applications.

Why is my FLAC file so much larger than an MP3 of the same song?

FLAC stores all original audio data — typically 700-1000 kbps for CD-quality stereo. MP3 at 192 kbps discards approximately 80% of the data using psychoacoustic masking. The size difference directly reflects the data retention difference between lossless and lossy compression.

What compression level should I use when encoding FLAC?

Level 5 (the default). FLAC levels 0-8 trade encoding speed for file size — level 5 hits the practical sweet spot. Level 8 (maximum) squeezes only 3-5% more space but takes 8-10x longer to encode. All levels decode at the same speed because the decoder is unaware of which level was used. For archival where encode time is irrelevant, level 8 saves a few gigabytes across a large library.

Does FLAC support hi-res audio above CD quality?

Yes. FLAC handles up to 32 bits per sample and 655,350 Hz sample rate — far exceeding CD's 16-bit/44.1 kHz. In practice, 24-bit/96 kHz and 24-bit/192 kHz are common for hi-res downloads from HDtracks and Qobuz. The format was standardized as IETF RFC 9639 in 2024, ensuring long-term archival confidence for hi-res content.

What makes .FLAC special

Truly lossless
Bit-for-bit identical to the original
FLAC includes an MD5 hash of the uncompressed audio in the STREAMINFO block. Run flac --test to verify perfect roundtrip integrity.
Open source
BSD-licensed since 2001
Josh Coalson released FLAC under a BSD license via Xiph.Org. Fully free, no patents, no royalties. The de facto standard for lossless audio archival.
Compression levels
Level 5 to 8: 3-5% gain, 10x slower
FLAC level 5 is the default sweet spot. Level 8 squeezes 3-5% more space but takes 8-10x longer to encode. Both decode at the same speed.
Half the size of WAV
Saves 40-60% with zero quality loss
A CD-quality FLAC file averages 5 MB per minute versus WAV at 10 MB. The savings add up to hundreds of GB across a large music library.

Lossless audio compression in FLAC recovers the original PCM waveform bit-for-bit after decoding — no samples are discarded, no frequency bands are attenuated, and no psychoacoustic model decides what you can or cannot hear. A typical CD-quality stereo file (16-bit, 44.1 kHz) compresses to 50–65% of the original WAV size, saving 400–600 MB per album while preserving every sample.

Continue reading — full technical deep dive

How FLAC compression works

FLAC uses a prediction-plus-residual architecture. For each block of audio samples, the encoder fits a predictor — either a simple fixed polynomial or a linear predictive coding (LPC) model — to the waveform. The predictor estimates each sample based on preceding samples. The encoder then stores only the residual: the difference between the predicted value and the actual value. Because a good predictor tracks the signal closely, residuals cluster near zero and compress efficiently.

Those residuals are encoded using Rice coding (a variant of Golomb coding optimized for geometric distributions). The encoder tests multiple Rice parameters per partition and selects the one that produces the smallest output. This is where FLAC spends most of its computation during encoding.

Each channel within a frame can use a different coding strategy. FLAC supports independent coding (each channel compressed separately), left-side, right-side, and mid-side stereo decorrelation. Mid-side mode stores the sum and difference of left and right channels; when the channels are similar — common in most stereo recordings — the difference signal is small and compresses tightly.

Frame structure

A FLAC stream is a sequence of frames, each self-contained. Every frame begins with a sync code (0xFFF8 or 0xFFF9), followed by a header that records the block size, sample rate, channel assignment, bit depth, and a frame or sample number. After the header, each channel gets its own subframe containing the predictor order, predictor coefficients (for LPC), and the Rice-coded residuals. A CRC-8 protects the frame header; a CRC-16 covers the entire frame. If a single bit flips in storage or transmission, the decoder detects it at the frame level without corrupting the rest of the stream.

Block size is configurable. The default is 4096 samples for most sample rates. Larger blocks give the predictor more context and marginally better compression. Smaller blocks reduce decode latency and improve seek granularity.

Compression levels and diminishing returns

FLAC offers compression levels 0 through 8. Level 0 uses fixed predictors, small block sizes, and minimal partition search. Level 8 uses high-order LPC predictors (up to order 12), exhaustive partition search, and larger blocks. FLAC compression level 0 vs level 8 differs by only 3–5% in file size but encoding time increases 8–10x — level 5 (the default) hits the knee of the curve. Beyond level 5, each increment buys fractions of a percent in size reduction while doubling or tripling encode time. For archival encoding where time is irrelevant, level 8 saves a few gigabytes across a large library. For real-time recording or batch processing, level 5 is the practical ceiling.

Seek table and random access

FLAC files include an optional seek table in the metadata — a list of sample numbers mapped to byte offsets within the stream. Players use the seek table to jump to any point in the file without decoding from the start. Without a seek table, seeking still works (the decoder scans for sync codes), but it is slower on large files or network streams. Most encoders generate a seek table by default with one entry every 10 seconds.

Metadata: Vorbis comments and album art

FLAC uses the Vorbis comment system for metadata — the same key-value tag format used by Ogg Vorbis. Tags are UTF-8 strings, case-insensitive, and support arbitrary fields beyond the standard ARTIST, ALBUM, TITLE set. ReplayGain values are stored as Vorbis comments.

Album art is embedded via METADATA_BLOCK_PICTURE, a binary metadata block that stores the image type (front cover, back cover, etc.), MIME type, description, dimensions, and the raw image data. Multiple picture blocks are allowed. Some older software writes album art as a Vorbis comment with base64-encoded image data instead — this works but inflates the metadata size by roughly 33%.

Subset mode and streaming

FLAC defines a "subset" — a restricted set of encoding parameters that all conformant decoders must support. Subset mode limits block size to 4608 samples at 48 kHz and below (16384 above 48 kHz), predictor order to 12, and Rice partition order to 8. Files encoded within subset constraints are guaranteed to stream and decode on any FLAC-compatible device. Non-subset files may use higher predictor orders or unconventional block sizes that some hardware decoders reject.

Ogg FLAC

FLAC can be encapsulated in an Ogg container, producing Ogg FLAC files (typically .oga extension). Ogg FLAC adds Ogg's framing, multiplexing, and chained stream features. This matters for internet radio and streaming servers built on the Icecast/Ogg infrastructure. Native FLAC is more common for file storage; Ogg FLAC fills a niche in live streaming.

FLAC vs alternatives

ALAC (Apple Lossless) compresses to similar ratios — within 1–2% of FLAC on most material. ALAC's advantage is native support in Apple's ecosystem: iTunes, Music app, iPhone, AirPlay. FLAC is supported everywhere else and has broader hardware player compatibility (most dedicated audio players, Android, car systems, Sonos, and all major streaming DACs).

WavPack offers a hybrid mode that produces a lossy file plus a correction file; combining both recovers the lossless original. This is unique among lossless codecs. WavPack also supports 32-bit float samples natively. Compression ratios are comparable to FLAC, sometimes 1–2% better on specific material.

APE (Monkey's Audio) compresses 2–5% smaller than FLAC on average but decodes significantly slower. High-compression APE files can strain low-power hardware decoders. The format also lacks a seek table, making random access expensive on large files.

Limitations

FLAC has no DRM mechanism. This is by design — the format is open and patent-free — but it means services requiring copy protection cannot use it for distribution.

Channel count maxes out at 8. For immersive audio formats like Dolby Atmos or 22.2 surround, FLAC cannot carry the full bed and object layout in a single stream.

There is no lossy mode. If you want lossy compression from the same ecosystem, Opus (for general audio) or Vorbis (legacy) are the Xiph.org alternatives. FLAC is strictly lossless.

Maximum bit depth is 32 bits per sample. Maximum sample rate is 655,350 Hz. In practice, 24-bit/192 kHz is the highest common configuration, and FLAC handles it without issue.

When to choose FLAC

Use FLAC for music archival, library storage, and any workflow where preserving the original recording matters. It is the standard lossless format for Linux, Android, and most non-Apple hardware.

Use WAV when you need uncompressed PCM for DAW editing, plugin compatibility, or broadcast ingest chains that expect raw audio. WAV avoids any decode overhead but costs 35–50% more storage.

Use ALAC if your playback chain is exclusively Apple hardware and software. The compression and quality are equivalent to FLAC; only the compatibility matrix differs.

Use Opus at 128–160 kbps for transparent lossy quality at a fraction of the file size. Opus outperforms AAC and MP3 at every bitrate and is the correct choice when storage or bandwidth constraints make lossless impractical.

.FLAC compared to alternatives

.FLAC compared to alternative formats
Formats Criteria Winner
.FLAC vs .ALAC
Compression ratio
FLAC typically compresses 2-5% better than ALAC on identical source material. Both are lossless, but FLAC's prediction models and Rice coding are slightly more efficient than ALAC's adaptive linear prediction.
FLAC wins
.FLAC vs .WAV
File size
FLAC achieves 50-70% compression versus WAV with zero quality loss. Both decode to identical PCM. FLAC adds a few milliseconds of decode latency but saves significant storage and bandwidth.
FLAC wins
.FLAC vs .MP3
Audio fidelity
FLAC is lossless — bit-perfect reproduction of the original recording. MP3 discards masked frequencies. The difference is measurable on all source material but may be inaudible at high MP3 bitrates.
FLAC wins
.FLAC vs .ALAC
Platform support
ALAC is natively supported across the entire Apple ecosystem (iPhone, iPad, Mac, Apple Music, AirPlay) without configuration. FLAC requires iOS 11+ and is not the default lossless format in Apple Music.
ALAC wins

Technical reference

MIME Type
audio/flac
Magic Bytes
66 4C 61 43 fLaC signature.
Developer
Xiph.Org Foundation
Year Introduced
2001
Open Standard
Yes — View specification
00000000664C6143 fLaC

fLaC signature.

Binary Structure

FLAC files begin with a 4-byte magic number (66 4C 61 43 / 'fLaC'), followed by one or more metadata blocks, then audio frames. The first metadata block is always STREAMINFO (type 0, 34 bytes): minimum and maximum block size (2+2 bytes), minimum and maximum frame size (3+3 bytes), sample rate (20 bits), number of channels minus 1 (3 bits), bits per sample minus 1 (5 bits), total samples (36 bits), and MD5 signature of the uncompressed audio (16 bytes). Subsequent metadata blocks are optional: PADDING (type 1), APPLICATION (type 2), SEEKTABLE (type 3), VORBIS_COMMENT (type 4), CUESHEET (type 5), and PICTURE (type 6). Each metadata block header is 4 bytes: 1-bit last-block flag, 7-bit type, and 24-bit length. Audio frames follow, each self-contained with a frame header (sync code 0xFFF8 or 0xFFF9), subframe predictors, and Rice-coded residuals.

OffsetLengthFieldExampleDescription
0x00 4 bytes FLAC Magic 66 4C 61 43 (fLaC) Identifies the file as a native FLAC stream. Always the first 4 bytes.
0x04 4 bytes STREAMINFO Block Header 00 00 00 22 Metadata block header: bit 0 = last-block flag (0 = more blocks follow), bits 1-7 = type (0 = STREAMINFO), bits 8-31 = length (0x22 = 34 bytes).
0x08 4 bytes Min/Max Block Size 10 00 10 00 Minimum and maximum block size in samples (2 bytes each). 0x1000 = 4096 samples per block.
0x12 3 bytes Sample Rate + Channels + Bit Depth 0A C4 42 20 bits sample rate + 3 bits channels-1 + 5 bits bps-1. Packed bitfield requiring bit-level parsing.
0x22 16 bytes MD5 Signature varies MD5 hash of the original uncompressed audio. Used to verify lossless roundtrip integrity after decoding.
2001Josh Coalson releases FLAC 1.0 as an open-source lossless audio codec under Xiph.Org2003FLAC incorporated into the Xiph.Org Foundation alongside Vorbis and Ogg projects2017Apple adds native FLAC playback in iOS 11 and macOS High Sierra; Tidal and Amazon Music adopt FLAC for lossless streaming tiers2024FLAC formally standardized as IETF RFC 9639 — completing a 21-year journey from Internet-Draft to Proposed Standard2021Apple Music launches Lossless Audio tier using ALAC, driving renewed interest in lossless formats including FLAC
Convert FLAC to MP3 at high quality ffmpeg
ffmpeg -i input.flac -codec:a libmp3lame -qscale:a 2 output.mp3

-codec:a libmp3lame selects the LAME encoder. -qscale:a 2 produces VBR quality level 2 (~190 kbps), considered transparent for most listeners. Encoding from FLAC gives the best possible MP3 since the source is lossless.

Decode FLAC to WAV (lossless) ffmpeg
ffmpeg -i input.flac -c:a pcm_s16le output.wav

-c:a pcm_s16le writes signed 16-bit little-endian PCM. The output WAV is bit-identical to the original uncompressed audio. Use pcm_s24le for 24-bit source material.

Compress WAV to FLAC with maximum compression other
flac --best input.wav -o output.flac

--best selects maximum compression (level 8). The reference FLAC encoder from Xiph.Org. Output is lossless — decode produces identical PCM to the input WAV.

Verify FLAC file integrity other
flac --test input.flac

Decodes the FLAC file and compares the MD5 of the output against the MD5 stored in the STREAMINFO block. Reports pass/fail without writing output.

Batch convert FLAC to MP3 ffmpeg
for f in *.flac; do ffmpeg -i "$f" -codec:a libmp3lame -qscale:a 2 "${f%.flac}.mp3"; done

Iterates over all FLAC files in the current directory and converts each to MP3 at VBR quality 2. The output filename replaces .flac with .mp3.

FLAC MP3 transcode lossy MP3 encoding reduces FLAC to approximately 10% of its size while maintaining perceptually acceptable quality. Required for portable devices with limited storage, car stereos with no FLAC support, and podcast/streaming platforms that mandate lossy formats.
FLAC WAV transcode lossless WAV is the universal interchange format for DAWs. Decoding FLAC to WAV is a lossless operation — the output is bit-identical to the original uncompressed audio, verified by the STREAMINFO MD5 checksum.
FLAC OGG transcode lossy Vorbis in OGG provides patent-free lossy compression for web and game audio. Encoding directly from FLAC (instead of a lossy source) produces the best possible Vorbis output with a single generation of lossy encoding.
FLAC AAC transcode lossy AAC is the native audio codec for Apple devices, YouTube, and most streaming services. Encoding from FLAC source produces optimal AAC quality since the encoder works from uncompressed PCM data.
LOW

Attack Vectors

  • Malformed STREAMINFO block with extreme sample rate or channel count values can cause integer overflow in decoders calculating buffer sizes
  • Oversized PICTURE metadata block with crafted JPEG or PNG data can trigger vulnerabilities in image decoders invoked by media players for album art display
  • Recursive SEEKTABLE entries pointing to invalid offsets can cause infinite loops in seek implementations without bounds checking

Mitigation: FileDex processes FLAC files entirely in the browser using FFmpeg WebAssembly in a sandboxed environment. No FLAC data is uploaded to any server. Audio decoding happens locally with memory-safe WASM execution.

Official FLAC encoder/decoder from Xiph.Org — the reference implementation
FFmpeg tool
Universal media framework with native FLAC encoding and decoding support
foobar2000 tool
Lightweight audiophile music player with native FLAC, ReplayGain, and gapless playback
libFLAC library
C library for encoding and decoding FLAC streams, used by most FLAC-capable applications
Automatic audio tagger using acoustic fingerprinting with full FLAC Vorbis Comment support