# .svg MIME Type: image/svg+xml

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

- MIME type: `image/svg+xml`
- Extensions: .svg
- Content-Type header: `image/svg+xml`
- Compress in transit: yes

## 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.

## Server configuration

### 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">
```

## FAQ

### 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

- [.png — image/png](https://www.devkult.com/mime/png.md)
- [.xml — application/xml](https://www.devkult.com/mime/xml.md)
- [.ico — image/vnd.microsoft.icon](https://www.devkult.com/mime/ico.md)

Open the interactive page: https://www.devkult.com/mime/svg