Setup & site building · Info
Can You Upload Svg to WordPress? The Short Answer

Short answer
Not by default. WordPress blocks SVG uploads because SVG files can contain scripts used in cross-site scripting attacks. You can allow them safely with a plugin that sanitizes each file, such as Safe SVG, or with code that restricts uploads to trusted users and cleans the files.
Key takeaways
- WordPress core blocks SVG uploads by default.
- SVG files can carry scripts, so sanitizing matters.
- Safe SVG allows uploads and cleans each file.
- The upload_mimes filter alone does not sanitize.
- Limit SVG uploads to trusted user roles.
- Use SVG for logos and icons, not photos.
Can you upload SVG files to WordPress?
Not by default: WordPress blocks SVG uploads for security reasons, but you can allow them safely with a plugin that sanitizes each file, such as Safe SVG.
If you try to upload an SVG to the Media Library on a standard site, you see an error saying you are not allowed to upload this file type.
That is deliberate. SVG files are code, not just pictures, and a malicious one can run scripts in a visitor's or admin's browser.
The good news is that SVG support takes a few minutes to add properly. The key is to sanitize files and limit who can upload them.
Why does WordPress block SVG uploads?
WordPress blocks SVG because an SVG is an XML document that can contain JavaScript and external references, which attackers can use for cross-site scripting.
A PNG or JPEG contains only pixel data. An SVG, by contrast, is text markup that browsers interpret, much like a small web page.
If a harmful SVG is uploaded and later opened directly, embedded script can run on your domain. That can steal session cookies or take actions as the logged-in user.
This type of attack is known as cross-site scripting. It is why WordPress core leaves SVG off its list of allowed file types.
Why would you want SVG files on your site?
SVG files stay sharp at any size, are usually tiny for logos and icons, and can be styled or animated with CSS.
A logo saved as SVG looks crisp on phones, laptops and high-density screens without needing multiple image sizes.
Simple icons and illustrations are often only a few kilobytes as SVG, much smaller than equivalent PNG files.
SVG is not right for photos, though. Photos belong in JPEG, WebP or AVIF, covered in our guide on how to serve images in next-gen formats.
What are the ways to allow SVG uploads?
You can use a sanitizing plugin, add code to allow the SVG file type, or skip uploads and paste SVG code into a Custom HTML block.
| Method | Sanitizes files | Effort | Best for |
|---|---|---|---|
| Safe SVG plugin | Yes | Low | Most sites |
| SVG Support plugin | Option to sanitize | Low | Sites that also want inline SVG |
| upload_mimes code snippet | No, unless you add it | Medium | Developers with their own sanitizer |
| Custom HTML block | Not applicable | Low | One-off icons |
| Theme or builder SVG feature | Varies | Low | Logos in supported themes |
For most site owners, a plugin that sanitizes uploads is the right choice. It handles the security work you would otherwise need to code yourself.
How do you upload SVG with the Safe SVG plugin?
Install and activate Safe SVG from the plugin directory, then upload SVG files to the Media Library as you would any image.
- Go to Plugins > Add New Plugin and search for Safe SVG.
- Install and activate it.
- Open Media > Add New Media File and upload your SVG.
- Insert the SVG with an Image block, or set it as your site logo.
Safe SVG cleans each file as it is uploaded, removing scripts and other risky content. It also helps SVG thumbnails show in the Media Library.
Check the plugin page for its current settings. Some versions let you choose which user roles may upload SVG files.
How do you allow SVG uploads with code?
Developers can allow SVG with the upload_mimes filter, but this alone does not sanitize files, so pair it with a sanitizer and limit uploads to trusted roles.
A basic snippet looks like this:
add_filter( 'upload_mimes', function ( $mimes ) {
if ( current_user_can( 'manage_options' ) ) {
$mimes['svg'] = 'image/svg+xml';
}
return $mimes;
} );
This only allows Administrators to upload SVG. Place it in a small custom plugin or a code snippets plugin rather than a parent theme.
The WordPress upload_mimes reference explains the filter. WordPress also checks the real file type, so some SVG files still fail if they lack a proper XML or svg header.
Do not stop at allowing the MIME type on a site with many users. Without sanitizing, you are trusting every uploaded file.
Can you add SVG without uploading a file?
Yes, you can paste SVG markup into a Custom HTML block, which avoids the Media Library entirely and works well for single icons.
Open the editor, add a Custom HTML block, and paste the SVG code. Preview the block to check it renders.
This approach only works for users allowed to post unfiltered HTML, which on single sites is usually Administrators and Editors.
Inline SVG is not reusable across many pages without copying it. For logos and repeated icons, uploading through a sanitizing plugin is tidier.
Can you use an SVG as your site logo?
Yes, once SVG uploads are allowed, many themes and the Site Logo block accept SVG files, though some older themes expect PNG or JPEG and may crop or resize oddly.
Upload the SVG first, then set it as the logo in the Site Editor or Appearance > Customize, depending on your theme.
If the logo shows at zero height or does not appear, the SVG may be missing width and height or a viewBox attribute. Open the file in a code editor and check the svg tag.
Our guide on how to change the logo in WordPress covers both block and classic themes.
Is it safe to allow SVG uploads?
It is reasonably safe if you sanitize every file, restrict uploads to trusted roles, and only use SVGs from sources you trust.
Sanitizing removes scripts and event handlers that cause most attacks. That is why plugins built for SVG are safer than a bare code snippet.
Limit uploads to Administrators or Editors on sites with open registration or many contributors. Fewer uploaders means less risk.
Pair this with good general security. Our explainer on what a security plugin does covers the other layers worth having.
Why does your SVG upload still fail?
If uploads still fail, the plugin may not cover your role, the file may lack a valid SVG header, or a security plugin or host rule may be blocking it.
Open the file in a text editor. It should start with an XML declaration or an svg tag. Files exported from some tools include extra data that confuses type checks.
Re-export the file from your design tool as plain SVG, or run it through an optimiser such as SVGO to clean it up.
If you see a generic upload error, check our guide on the error that occurred in the upload for server-side causes.
Should you use ALLOW_UNFILTERED_UPLOADS?
No, avoid it on live sites, because that wp-config constant lets Administrators upload almost any file type without sanitizing, which is far broader than you need for SVG.
It can be handy for a short, controlled task on a private site. Remove it as soon as you finish.
For ongoing SVG use, a sanitizing plugin is the safer and more targeted choice. It allows the one file type you need and cleans it on the way in.
Once SVG is set up, keep your logos and icons as SVG and your photos in modern raster formats. Our guide on how to optimize images for WordPress covers the rest.
Frequently asked questions
Why do I get an error saying I am not allowed to upload this file type?
WordPress does not include SVG in its list of allowed upload types, so the Media Library rejects it. Install a sanitizing SVG plugin or add code that allows the SVG MIME type for trusted roles, then try the upload again.
Is Safe SVG free?
Safe SVG is available for free in the WordPress plugin directory and covers sanitizing uploads and showing previews in the Media Library. Check the plugin page for any premium extras or role settings in the current version before installing.
Do SVG files slow down WordPress?
Usually the opposite for logos and icons, because simple SVG files are often smaller than PNG equivalents. Very complex SVG illustrations with thousands of paths can be heavy, so optimise them before upload and use raster formats for photos.
Can Editors upload SVG files?
That depends on your setup. Plugins and code can allow SVG for specific roles. Many sites limit SVG uploads to Administrators, but allowing Editors is reasonable if they are trusted staff and files are sanitized.
Will SVG images work in all browsers?
Yes. All modern browsers display SVG images. Problems usually come from the file itself, such as missing width, height or viewBox attributes, which can make an SVG render at the wrong size or not at all.
Sources
- Safe SVG WordPress.org Plugins
- upload_mimes hook WordPress Developer Resources
- SVG: Scalable Vector Graphics MDN Web Docs
- Cross Site Scripting (XSS) OWASP
- SVG Support WordPress.org Plugins
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


