Almindelige MIME-typer
Servere og uploadformularer er afhængige af disse strenge; en forkert type kan ødelægge forhåndsvisninger, downloads eller din Content Security Policy.
| Art | MIME-type | Typisk endelse |
|---|---|---|
| HTML | text/html | .html |
| CSS | text/css | .css |
| JavaScript | text/javascript | .js |
| JSON | application/json | .json |
| XML | application/xml | .xml |
| Plain text | text/plain | .txt |
| CSV | text/csv | .csv |
| application/pdf | ||
| ZIP | application/zip | .zip |
| PNG | image/png | .png |
| JPEG | image/jpeg | .jpg |
| GIF | image/gif | .gif |
| WebP | image/webp | .webp |
| SVG | image/svg+xml | .svg |
| ICO | image/x-icon | .ico |
| MP3 | audio/mpeg | .mp3 |
| WAV | audio/wav | .wav |
| MP4 | video/mp4 | .mp4 |
| WebM | video/webm | .webm |
| WOFF2 | font/woff2 | .woff2 |
| Form URL-encoded | application/x-www-form-urlencoded | — |
| Multipart form | multipart/form-data | — |
Noter
- Nogle browsere sniffer indhold; send alligevel den korrekte type fra din server.
- Den officielle JS-type er text/javascript (application/javascript er forældet).
Ofte stillede spørgsmål
- Hvilken MIME-type skal jeg bruge til en .json-fil?
- Brug application/json til JSON-filer og API-svar. Det er standardtypen og bør sendes med UTF-8, hvor det er muligt.
- Hvilken MIME-type bruger .js-filer?
- Den officielle type for JavaScript er text/javascript. Den ældre application/javascript er forældet og bør ikke længere bruges.
- Hvilken MIME-type bruger et SVG-billede?
- SVG-filer bruger image/svg+xml. Sørg for at sende dem som SVG og ikke som image/xml, ellers viser browsere dem ikke inline.