About FLAC audio files
Lossless compression, typically about half the size of WAV with identical sound. All current browsers play FLAC in <audio>. Older systems used audio/x-flac.
Other types seen for these files:
audio/x-flac
. Accept them when reading uploads, but send audio/flac yourself.
File signature
FLAC files start with 66 4C 61 43 ("fLaC"). The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .flac with the right Content-Type
Content-Type: audio/flac
audio/flac flac;
AddType audio/flac .flac
@flac path *.flac
header @flac Content-Type "audio/flac"
curl -sI https://example.com/file.flac | grep -i '^content-type'
# Content-Type: audio/flac
Set the type in code
res.set('Content-Type', 'audio/flac');
// Or make the browser download it:
res.attachment('file.flac');
import mimetypes
mimetypes.add_type('audio/flac', '.flac') # if your system doesn't know it
mimetypes.guess_type('file.flac')[0] # 'audio/flac'
mime.AddExtensionType(".flac", "audio/flac")
w.Header().Set("Content-Type", "audio/flac")
Accept .flac uploads
<input type="file" accept=".flac,audio/flac">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
More audio
.m4a , .aac . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .flac files?
audio/flac. You may also see audio/x-flac, which is older or unofficial; send audio/flac. The full header is "Content-Type: audio/flac".
Why does my server send the wrong Content-Type for .flac?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .flac is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is FLAC?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. FLAC files start with 66 4C 61 43 ("fLaC"). The MIME type lookup on this site reads them for you when you drop a file on it.