DevToolsmith

MP3 MIME Type

audio/mpeg is the MIME type for MP3 audio. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
audio/mpeg
Extensions
.mp3
Content-Type header
audio/mpeg
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Audio

About MP3 audio files

The registered type is audio/mpeg; audio/mp3 is a widespread mistake that browsers tolerate. For seeking in <audio> to work, the server must support range requests (Accept-Ranges: bytes and 206 responses).

Other types seen for these files: audio/mp3 , audio/mpeg3 . Accept them when reading uploads, but send audio/mpeg yourself.

File signature

MP3 files start with 49 44 33 ("ID3" tag), or FF FB / FF F3 / FF F2 (frame sync) without tags. 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 .mp3 with the right Content-Type

Response header
Content-Type: audio/mpeg
nginx (a line in the types { } block of mime.types)
audio/mpeg mp3;
Apache (.htaccess or server config)
AddType audio/mpeg .mp3
Caddy
@mp3 path *.mp3
header @mp3 Content-Type "audio/mpeg"
Check what a server sends
curl -sI https://example.com/file.mp3 | grep -i '^content-type'
# Content-Type: audio/mpeg

Set the type in code

Node.js (Express)
res.set('Content-Type', 'audio/mpeg');
// Or make the browser download it:
res.attachment('file.mp3');
Python
import mimetypes

mimetypes.add_type('audio/mpeg', '.mp3')  # if your system doesn't know it
mimetypes.guess_type('file.mp3')[0]  # 'audio/mpeg'
Go
mime.AddExtensionType(".mp3", "audio/mpeg")
w.Header().Set("Content-Type", "audio/mpeg")

Accept .mp3 uploads

HTML
<input type="file" accept=".mp3,audio/mpeg">

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

  • .m4a (audio/mp4): M4A audio
  • .ogg (audio/ogg): Ogg audio
  • .wav (audio/wav): WAV audio
  • .aac (audio/aac): AAC audio

More audio

.flac . 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 .mp3 files?

audio/mpeg. You may also see audio/mp3, audio/mpeg3, which are older or unofficial; send audio/mpeg. The full header is "Content-Type: audio/mpeg".

Why does my server send the wrong Content-Type for .mp3?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .mp3 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 MP3?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. MP3 files start with 49 44 33 ("ID3" tag), or FF FB / FF F3 / FF F2 (frame sync) without tags. The MIME type lookup on this site reads them for you when you drop a file on it.