Scalable Vector Graphics
image/svg+xml
Released 2001
· by World Wide Web Consortium (W3C)
Scalable Vector Graphics (SVG) is the web standard for two-dimensional, XML-based vector graphics. Because it uses mathematical formulas (points, lines, curves, and shapes) rather than a grid of pixels, it scales infinitely without losing quality. The image/svg+xml MIME type is the officially registered IANA identifier. SVGs support CSS styling, DOM manipulation, SMIL animations, and JavaScript interactivity.
Technical Specifications
.svg.svgz
None (for .svg)GZIP (for .svgz)
image/svg
Magic Bytes & HTTP Headers
<svg / <?xml
Browser Support Matrix
| Browser | Status | Min Version |
|---|---|---|
|
|
Supported | All |
|
|
Supported | All |
|
|
Supported | All |
|
|
Supported | All |
|
|
Supported | Legacy |
Advantages & Limitations
- Provides infinite resolution scalability, looking perfectly crisp on high-DPI (Retina) displays without increasing file size
- Extremely lightweight compared to raster formats for flat graphics, logos, and UI elements
- Can be manipulated dynamically via the browser's CSS and JavaScript engines (DOM integration)
- Unsuitable for complex photographic images or photorealistic textures
- Poses critical security vulnerabilities (XSS and XML External Entity attacks) if user-uploaded SVGs are not heavily sanitized
- Rendering performance degrades significantly if the SVG contains tens of thousands of complex nodes or deeply nested paths
Developer Code Snippets
File Detection Steps
How to programmatically detect a image/svg+xml
file by reading its raw bytes:
- 1 Check the initial bytes for plain text strings like '<?xml' or '<svg'
- 2 Parse the XML structure to ensure the root element is <svg> and belongs to the 'http://www.w3.org/2000/svg' namespace
Software Support
Conversion Tools
Share & Embed
[](https://freewebptojpg.com/mime/image/svg)
<iframe src="https://freewebptojpg.com/mime/image/svg/embed" width="100%" height="280" style="border:1px solid #cbd5e1;border-radius:8px;" title="SVG Specs"></iframe>
JSON API
All data on this page is available as a free, open JSON API. Use it in your project, documentation, or tooling.
GET https://freewebptojpg.com/mime/image/svg.json
Open JSON
Frequently Asked Questions
Why is the MIME type image/svg+xml instead of just image/svg?
The '+xml' suffix is a standardized convention in IANA MIME types indicating that the format is based on XML. This allows HTTP clients and browsers to pass the file through a generic XML parser if a specialized SVG renderer is unavailable. Serving SVGs simply as 'image/svg' violates standards and can cause strict MIME-sniffing browsers to reject the file.
What is the magic byte for an SVG file?
Because SVG is a plain-text XML format, it lacks a traditional binary magic number. Identification relies on reading the first few bytes as ASCII/UTF-8. Files typically begin with the XML declaration (<?xml version="1.0"?>) or the opening tag (<svg>). The hex for '<svg' is 3C 73 76 67.
Are there security risks when users upload SVGs?
Yes. SVG files are essentially HTML-like documents that can contain embedded <script> tags. If you allow users to upload SVGs and serve them directly from your main domain, attackers can execute Stored Cross-Site Scripting (XSS) attacks. Always sanitize user-uploaded SVGs using tools like DOMPurify, or serve them from a separate, sandboxed CDN domain.