devkult_
tools29converters34
home/mime/.svg

.svg MIME type

SVG imageimages

image/svg+xml

Vector graphics in XML. Text-based, so it compresses well.

MIME typeimage/svg+xml
Extensions.svg
Content-Typeimage/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 with Content-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