Author image Thomas Drugeon - INA


MIME::DB - Media Type Database, a port of the mime-db JavaScript package


    use MIME::DB;
    my $db = MIME::DB->data;


MIME::DB is a direct port of the mime-db JavaScript package.


The database does not include any logic, allowing it to remain as un-opinionated as possible.

    my $db = MIME::DB->data;

    my @known_html_extensions = @{ $db->{'text/html'}->{extensions} || [] };

    my $version = MIME::DB->version;

    print "As of version $version:\n";

    for (qw(text/html video/mp4 text/yaml)) {
        if (defined $db->{$_}->{compressible}) {
            if ($db->{$_}->{compressible}) {
                print "  - $_ is compressible\n"
            } else {
                print "  - $_ is not compressible\n"
        } else {
            print "  - $_ compressibility is unknown\n"

returns the database as a HASH reference.

Each call to data returns an independent copy of the database, so it can be modified without affecting others.

It is highly recommended to store it in a variable if several calls are to be issued, for performance reasons.


returns the version of the database.

This might be different from $VERSION.

Data Structure

The database is a HASH reference with lowercased mime types as keys. Each value is a HASH reference with following keys:

  • source - where the mime type is defined. If not set, it's probably a custom media type.

    • apache - Apache common media types

    • iana - IANA-defined media types

    • nginx - nginx media types

  • extensions - an ARRAY reference of known extensions associated with this mime type.

  • compressible - a 0 or 1 value indicating whether a file of this type can be gzipped.

  • charset - the default charset associated with this type, if any.

If unknown, every property could be undefined.


mime-db github homepage


  • Thomas Drugeon, <>


mime-db is copyright 2014 Jonathan Ong and licensed under the MIT License

MIME::DB is copyright 2021 Thomas Drugeon and licensed under the MIT License