.svg MIME type
SVG imageimages
image/svg+xmlVector graphics in XML. Text-based, so it compresses well.
| MIME type | image/svg+xml |
|---|---|
| Extensions | .svg |
| Content-Type | image/svg+xml |
| Compress in transit? | Yes — enable gzip or Brotli |
Good to know
- SVG can contain scripts. User-uploaded SVGs opened directly run on your origin — sanitise them, or serve them as attachments or from another domain.
- Gzipped SVG files (
.svgz) use the same type withContent-Encoding: gzip. - Inline SVG in HTML needs no MIME type at all.
Useful here: SVG optimizer
Serve .svg files with the right type
The response header to send:
Content-Type: image/svg+xml
Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:
nginx (inside the types block in mime.types)
image/svg+xml svg;
Apache (.htaccess or server config)
AddType image/svg+xml .svg
Express
res.set("Content-Type", "image/svg+xml");Python
import mimetypes
mimetypes.add_type("image/svg+xml", ".svg")HTML file input
<input type="file" accept=".svg,image/svg+xml">
Check it
See what a server sends for a file, and what type a local file really is by its contents:
curl -sI https://example.com/file.svg | grep -i '^content-type:' file --mime-type file.svg
Frequently asked questions
What is the MIME type for .svg files?
image/svg+xml.
What Content-Type header should a .svg file be served with?
Content-Type: image/svg+xml. It compresses well, so let the server apply gzip or Brotli.
Related types
Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options