ImageToSVG

How to Add SVG Support to WordPress — Enable SVG Upload & Display

WordPress blocks SVG uploads by default for security — enable it safely with a plugin or code snippet and display SVG in posts and pages.

Preset:
Colors:
VTracer vectorization + SVGO optimizationPrivacy protected

Enabling SVG Upload in WordPress

WordPress blocks SVG uploads by default because SVG can contain JavaScript (XSS risk). Enable safely with the Safe SVG plugin, which sanitizes uploaded SVGs automatically. Or add a code snippet to functions.php to allow SVG with a mime type filter.

  • Safe SVG plugin: sanitizes on upload, best practice
  • Code: add_filter('upload_mimes', function($m){ $m['svg'] = 'image/svg+xml'; return $m; });
  • Always sanitize — never allow raw SVG from untrusted sources

Displaying Inline SVG in WordPress Posts

WordPress strips SVG markup from post content by default. To inline SVG in posts: use the Custom HTML block in Gutenberg and paste the SVG code directly. Or use a shortcode plugin to embed SVG from the media library as inline SVG.

  • Gutenberg: Custom HTML block → paste SVG code
  • SVG Block plugin: embed uploaded SVG as inline in page
  • Inline SVG enables CSS styling and hover interactivity

Frequently Asked Questions

Is it safe to enable SVG uploads in WordPress?

Yes, with the Safe SVG plugin — it sanitizes SVG files on upload using DOMPurify, removing scripts and unsafe attributes. Never enable SVG uploads without sanitization on sites that allow user uploads.

Why is my SVG not showing in WordPress after upload?

WordPress may not recognize the SVG mime type or the SVG has a render issue. Install Safe SVG plugin, regenerate thumbnails if needed, and test SVG rendering directly in a browser first.

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