What it is
A reference for common MIME types used in web development, email, and file systems.
Installation
This is a reference, no installation required.
Core Concepts
MIME (Multipurpose Internet Mail Extensions) types are standardized ways to identify the format of a file or data. They consist of a type and a subtype, separated by a slash (e.g., text/html).
Commands / Usage
Text Formats
text/plain: For plain text files.echo "This is plain text." > file.txttext/html: For HTML documents.echo "<h1>Hello</h1>" > page.htmltext/css: For CSS stylesheets.echo "body { color: blue; }" > style.csstext/javascriptorapplication/javascript: For JavaScript code.echo "console.log('Hello');" > script.jstext/xml: For XML documents.echo "<root><item>value</item></root>" > data.xml
Image Formats
image/jpeg: For JPEG images.# (Assume image.jpg exists)image/png: For PNG images.# (Assume image.png exists)image/gif: For GIF images.# (Assume image.gif exists)image/svg+xml: For SVG vector graphics.echo "<svg width='100' height='100'><circle cx='50' cy='50' r='40' fill='red'/></svg>" > graphic.svg
Audio and Video Formats
audio/mpeg: For MP3 audio files.# (Assume audio.mp3 exists)audio/ogg: For Ogg Vorbis audio files.# (Assume audio.ogg exists)video/mp4: For MP4 video files.# (Assume video.mp4 exists)video/webm: For WebM video files.# (Assume video.webm exists)
Application Formats
application/json: For JSON data.echo '{"name": "example", "value": 123}' > data.jsonapplication/xml: For XML data (can sometimes overlap withtext/xml).echo "<config><setting>on</setting></config>" > config.xmlapplication/pdf: For PDF documents.# (Assume document.pdf exists)application/zip: For ZIP archives.# (Assume archive.zip exists)application/octet-stream: A generic binary file type, often used as a fallback.# (Assume binary_data exists)application/x-www-form-urlencoded: Used for submitting HTML form data.# (Used implicitly by web forms)multipart/form-data: Used for submitting HTML form data that includes files.# (Used implicitly by web forms with file uploads)
Other Common Types
image/x-icon: For favicon files.# (Assume favicon.ico exists)font/woff2: For WOFF2 web fonts.# (Assume font.woff2 exists)
Common Patterns
- Setting Content-Type in
curl: When uploading files or sending specific data types.curl -X POST -H "Content-Type: application/json" --data '{"key": "value"}' http://example.com/api/data curl -X POST -F "file=@/path/to/your/image.png;type=image/png" http://example.com/upload - Identifying MIME type from a file (using
filecommand):file --mime-type -b /path/to/your/document.pdf # Output: application/pdf file --mime-type -b /path/to/your/image.jpg # Output: image/jpeg
Gotchas
text/javascriptvs.application/javascript: While both are used for JavaScript,application/javascriptis the more modern and preferred MIME type according to RFC 6838. Some older systems might still expecttext/javascript.text/xmlvs.application/xml: Similar to JavaScript,application/xmlis the more general and preferred type for XML.text/xmlis often used when the XML is known to be text-based and doesn’t necessarily conform to strict XML parsing rules (though this distinction is often blurred).application/octet-streamFallback: Browsers will typically prompt the user to download files with this MIME type, as they don’t know how to render them directly.- Custom MIME Types: You can define custom MIME types using the
application/x-prefix, but these are not standardized and should be used with caution, especially for interoperability.