Which mime type should I use for mp3

Which mime type should I use for mp3

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

The Correct MIME Type for MP3 Files

When serving audio files via PHP, selecting the right Content-Type header is often treated as a minor detail compared to optimizing streaming performance or handling transcoding pipelines. However, choosing an incorrect MIME type can lead to playback issues in browsers and improper handling by modern media players. The confusion usually stems from historical naming conventions and the evolution of how MPEG audio was categorized within the IANA registry.

The most common mistake developers encounter is using audio/x-mpeg-3. This string appears in older documentation and legacy listings, but it is technically deprecated. While some legacy servers might still accept it, modern browsers and media frameworks rely on standardized identifiers to determine whether a file can be played natively or needs a specific codec extension. Using audio/x-mpeg-3 signals to the user agent that the content is a specific variant of MPEG audio, but it lacks the clarity of the current standard.

Another option often seen in outdated lists is audio/mpeg3. This looks intuitive, as it suggests "audio" and "mpeg3," but this specific string has also fallen out of favor in the IANA registry updates. Historically, MP3 files were indeed MPEG audio at Layer 3, but as the format matured, the naming convention shifted to simply refer to them as MPEG audio without the layer distinction in the header name.

The current standard and recommended MIME type for .mp3 files is audio/mpeg. This identifier aligns with how modern operating systems and browsers categorize the file. When you serve a file from a PHP script, setting the header correctly ensures that the browser knows exactly what to expect: raw MPEG audio data.

Here is how you should implement this in a typical PHP context using the header() function:

<?php
$file = 'music.mp3';
$mime_type = 'audio/mpeg';

// Ensure output buffering is not interfering with headers
if (ob_get_level()) {
    ob_end_clean();
}

// Send the correct header
header('Content-Type: ' . $mime_type);

// Optionally send caching headers for static assets
header('Cache-Control: public, must-revalidate');

// Serve the file
readfile($file);
exit;

Using audio/mpeg avoids the ambiguity associated with video/mpeg or video/x-mpeg. The latter two are reserved for video containers like MPEG-4 or raw video streams, not audio-only tracks. Confusing these can cause browsers to attempt to render an MP3 as a video file, resulting in a black screen or a download prompt instead of playback.

There is also the question of encoding variants. While standard MP3 files are almost exclusively served as audio/mpeg, there are edge cases involving MPEG-2 Audio or MPEG Surround. In these specific scenarios, the header might vary slightly, but for the vast majority of web-facing applications dealing with .mp3 extensions, audio/mpeg is the definitive choice.

It is worth noting that some frameworks or server configurations might default to a generic application/octet-stream. While this prevents immediate errors, it forces browsers into download mode rather than playback mode. Explicitly setting audio/mpeg in your application code, whether via PHP headers or an .htaccess rule, ensures a seamless user experience.

If you are working within a larger framework like Laravel, ensuring MIME types are handled correctly often involves configuring the server or using the framework's response helpers. For instance, when returning a file download or stream from a controller, explicitly setting the media type prevents the framework from guessing incorrectly based on file extension alone. While tools like LaravelCompany offer resources for building robust applications, the fundamental responsibility of defining correct content types remains with the developer to ensure compatibility across different client environments.

Ultimately, sticking to audio/mpeg provides the best balance between adherence to modern standards and compatibility with existing media players. It avoids the pitfalls of legacy strings and ensures that your audio assets are recognized immediately upon request.

Our network