用于 Web 开发和 HTTP 通信的 MIME(多用途互联网邮件扩展)类型完整参考。
text/html.html.htmtext/css.csstext/javascript.js.mjstext/plain.txttext/csv.csvtext/xml.xmltext/markdown.md.markdowntext/calendar.icstext/tab-separated-values.tsvtext/vcard.vcf.vcardimage/jpeg.jpg.jpegimage/png.pngimage/gif.gifimage/webp.webpimage/svg+xml.svg.svgzimage/avif.avifimage/bmp.bmpimage/tiff.tif.tiffimage/ico.icoimage/x-icon.icoimage/heic.heicimage/apng.apngaudio/mpeg.mp3audio/ogg.oga.oggaudio/wav.wavaudio/webm.webaaudio/flac.flacaudio/aac.aacaudio/midi.mid.midiaudio/opus.opusaudio/mp4.m4avideo/mp4.mp4.m4vvideo/webm.webmvideo/ogg.ogvvideo/mpeg.mpeg.mpgvideo/quicktime.mov.qtvideo/x-msvideo.avivideo/3gpp.3gpvideo/x-matroska.mkvvideo/x-ms-wmv.wmvapplication/json.jsonapplication/ld+json.jsonldapplication/xml.xmlapplication/pdf.pdfapplication/zip.zipapplication/gzip.gzapplication/x-tar.tarapplication/x-7z-compressed.7zapplication/x-rar-compressed.rarapplication/javascript.jsapplication/ecmascript.esapplication/typescript.tsapplication/wasm.wasmapplication/octet-stream.*application/x-www-form-urlencoded-multipart/form-data-application/graphql.graphqlapplication/sql.sqlapplication/x-sh.shapplication/x-python-code.pycapplication/msword.docapplication/vnd.openxmlformats-officedocument.wordprocessingml.document.docxapplication/vnd.ms-excel.xlsapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet.xlsxapplication/vnd.ms-powerpoint.pptapplication/vnd.openxmlformats-officedocument.presentationml.presentation.pptxapplication/vnd.oasis.opendocument.text.odtapplication/vnd.oasis.opendocument.spreadsheet.odsapplication/vnd.oasis.opendocument.presentation.odpfont/ttf.ttffont/otf.otffont/woff.wofffont/woff2.woff2font/collection.ttcmultipart/mixed-multipart/alternative-multipart/related-message/rfc822.eml.mhtmessage/partial-application/json.jsonREST API responses, config files
text/html.htmlWeb pages served by browsers
text/css.cssStylesheets for web pages
text/javascript.jsJavaScript files (IANA official)
multipart/form-dataFile uploads in HTML forms
application/pdf.pdfDocument downloads & previews
image/webp.webpModern web images (best compression)
application/octet-stream.*Generic binary / force download
application/wasm.wasmWebAssembly modules
MIME 类型出现在 HTTP 响应的 Content-Type 标头中,使浏览器和客户端了解如何处理内容。
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 1024
{"status": "ok"}
# File upload request:
Content-Type: multipart/form-data; boundary=----FormBoundary123
# Force browser download:
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="report.xlsx"MIME(多用途互联网邮件扩展)类型是用于指示文档、文件或字节集合的性质和格式的标准标识符。由类型和子类型组成,例如 'text/html' 或 'application/json'。服务器和浏览器使用 MIME 类型来确定如何处理文件。
将 Content-Type HTTP 标头设置为适当的 MIME 类型。例如:Content-Type: application/json; charset=utf-8。Apache 和 Nginx 等 Web 服务器可以自动将文件扩展名映射到 MIME 类型。在 Express.js 中,使用 res.type('json') 或 res.setHeader('Content-Type', 'application/json')。
application/json 是 JSON 数据的官方 IANA 注册 MIME 类型,应始终使用。text/json 是非标准的,历史上曾使用过。现代 API、框架和浏览器都期望 JSON 有效负载使用 application/json。
使用 application/octet-stream 作为通用二进制下载类型,强制浏览器下载而不是显示文件。对于特定格式,使用适当的类型(例如 PDF 使用 application/pdf)。结合 Content-Disposition: attachment; filename='file.ext' 显示下载提示。