MIME information: filetype, encoding, gzip
Author JuliaWeb
7 Stars
Updated Last
1 Year Ago
Started In
March 2022


A small package to transform between file extensions and MIME types, with bonus features.


julia> using MIMEs

julia> m = mime_from_extension(".json")
MIME type application/json

julia> extension_from_mime(m)

julia> compressible_from_mime(m) # whether content of this MIME can/should be gzipped

julia> charset_from_mime(m)

julia> contenttype_from_mime(m) # the Content-Type HTTP header
"application/json; charset=utf-8"


This package uses the popular jshttp/mime-db database. This database is an aggregation of the following sources:

The function implementations, including resolution for conflicting extensions (nginx > apache > mime-db > IANA), is based on jshttp/mime-types.


The database is parsed and processed by us, and written directly to the source code (see #3). This means that the package has no dependencies, and loads very fast:

julia> @time import MIMEs; MIMEs.mime_from_path("a/foo.txt")
  0.023083 seconds (36.38 k allocations: 3.107 MiB, 39.83% compilation time)


While mostly cold and technical, this package contains a couple of opinionated choices:

  • We use multiple sources for MIME information, and when these sources have conflicting/duplicate information, we
  • text/javascript is used for .js and .mjs files, not application/javascript. This transition is still underway in official channels, but @fonsp prefers to start using text/javascript today. More info โ†’
  • text/julia is used for .jl files. This MIME is not (yet) official: More info โ†’

See also

  • tkf/MIMEFileExtensions.jl: Similar smaller package based on the Apache database, for MIME <-> extension conversion only. MIMEs.jl also contains additional MIME-related queries useful for writing servers.
  • JuliaIO/FileType.jl: File type (including MIME) detection based also on the file content.

Future development & scope

Future goals of MIMEs.jl:

  • All things MIME! If you are writing a web application in Julia and you are missing MIME-related functionality, let us know! Issues and Pull Requests are welcome.
  • This package will be regularly updated to match the (monthly) updates to jshttp/mime-db. Right now this is involves manually running the update script, but we might automate this in the future. More info โ†’

Required Packages

No packages found.