How to Use SVG in Strapi CMS
Strapi's media library needs specific configuration to accept SVG uploads, and the frontend consuming Strapi's API needs its own render strategy.
Drop your image here
Supports PNG, JPG, BMP, WEBP up to 5MB
Enabling SVG in the Strapi Media Library
Strapi's media library may restrict SVG uploads by default in some configurations due to the same XSS concerns other CMS platforms share — check the media library's upload settings and allowed MIME types configuration to ensure `image/svg+xml` is permitted for the content types that need it.
- SVG upload restrictions stem from the same XSS concerns as other CMS platforms
- Verify image/svg+xml is included in allowed MIME type configuration
- Settings may need adjustment depending on your Strapi version and setup
Consuming SVG from the Strapi API
Strapi's API returns uploaded media (including SVG) as a URL reference in the response JSON — the frontend application consuming that API renders the SVG via a standard `<img src="...">` tag pointing to Strapi's media URL, or fetches and inlines the SVG markup directly if component-level styling control is needed.
- Strapi's API returns a URL reference to the uploaded SVG file
- Frontend renders via <img src> or fetches and inlines the markup directly
- Inlining requires an extra fetch step but enables CSS styling control
Frequently Asked Questions
Why is SVG upload disabled in my Strapi media library?
Check your Strapi instance's security/upload plugin configuration — SVG may be excluded from allowed MIME types by default or by your specific setup's security policy; adjusting that configuration re-enables it.
Should I sanitize SVGs uploaded to Strapi by content editors?
If content editors are less trusted than full administrators, yes — server-side sanitization before storage remains good practice regardless of CMS platform, since SVG's script-embedding risk exists independent of Strapi specifically.
Related guides
Ready to Convert Your Image to SVG?
Free online converter — no sign-up, no watermarks, results in under 3 seconds.
Try It Free — Convert Image to SVG