Skip to content
Toolwright

SVG Sanitizer

SVG Sanitizer cleans an untrusted SVG by removing scripts, event handlers, embedded web pages, links to other sites and external styles, and lists exactly what was taken out. It runs in your browser. It is a first line of defense, so also sanitize on the server.

Tool 113 · Developer
Outside requests …How to checkRuns on this deviceWorks offline once opened

How to use SVG Sanitizer

  1. Paste the SVG or drop the file.
  2. Read the list of what was removed and check the cleaned picture.
  3. Copy or download the cleaned file.

Frequently asked questions

Is my file uploaded to be cleaned?

No. The cleaning runs in your browser. The file is not sent anywhere.

Why can an SVG be dangerous?

An SVG is code, not just a picture. It can contain scripts, event handlers, links that run JavaScript, and references to other sites that track whoever opens it. That matters most when you let users upload SVGs or paste them into a page.

What is removed?

Script elements, on-event attributes such as onclick, foreignObject and the HTML inside it, links that are not local to the file, CSS @import and external url(), and animations that could turn a link into script. Shapes, colour fades, clip paths, text and local references are kept.

Is this enough to make an upload feature safe?

It is a strong first step, not a guarantee. Always sanitize on your server too, serve user SVGs with a Content-Security-Policy, and show them through an img tag rather than inline when you can.

Why is my picture different afterwards?

If the picture depended on an external image, external font or script, that part is gone by design. The list of removed items shows what changed.

Next step

Cleaned the file? Optimize it for size next. Open SVG Optimizer.

  1. 110

    SVG Optimizer

  2. 109

    SVG Editor

  3. 108

    SVG to Data URI

  4. 007

    Chmod Calculator