SVG sanitizer
Remove scripts and trackers from SVG
SVG is code: it can run JavaScript and load files from other servers. Clean SVGs from users, clients or the web before you put them on your site, and see exactly what was taken out.
Runs in this tab. Nothing is uploaded.
Keep
Report
Paste an SVG or try the malicious sample.
Clean result
Sanitized code
Batch
| File | Removed | Actions |
|---|
What gets removed
- Scripts and handlers:
<script>, everyon…attribute, and animations (<set>,<animate>) that rewrite links or handlers. - Dangerous links:
javascript:,vbscript:anddata:links, including ones hidden with entities, tabs or odd capitalization, and under any XLink prefix. - Embedded HTML:
<foreignObject>and anything in the XHTML namespace. - External references:
<use>pointing outside the file, remote images,@import, remoteurl()in CSS and attributes,xml-stylesheetandxml:base. These can track whoever views the image. - Everything else that isn’t plain SVG: unknown elements, foreign-namespace attributes, DOCTYPE and entity declarations.
SVGMend uses an allowlist of SVG elements instead of hunting for known tricks, and checks every attribute and URL after decoding entities. The output is well-formed XML that is also safe to paste into HTML. For very high-risk uploads, also serve SVGs from a separate domain or convert them to PNG.
Questions
Can an SVG really contain malware?
An SVG opened directly in a browser, or pasted into a web page, can run JavaScript just like HTML. That can steal sessions on the site that hosts it. As an <img> it can’t run scripts, but it can still be opened on its own.
Is it safe to paste a malicious SVG into this page?
Yes. SVGMend parses the code as text and shows the cleaned result only as an image, so nothing in the file runs here.
Will sanitizing change how the image looks?
Normal artwork stays the same. Things that depend on removed features change: HTML in foreignObject, external images and fonts, and CSS loaded from other servers.
More SVG tools
- SVG RepairDiagnose and fix broken XML, missing xmlns or viewBox, editor junk, bad IDs and scripts.
- SVG OptimizerSVGO with plugin toggles, precision and multipass. Batch files and download a ZIP.
- SVG ViewerZoom and pan on a checkerboard or colour, see dimensions, file size and the element tree.
- SVG to PNGExport PNG, JPG or WebP at 1× to 8× or an exact width, with any background.
- SVG to JSXTurn an SVG into a React component with camelCase props, style objects and TypeScript.
- SVG to Data URIMinimal URL-encoding or base64, ready-made CSS background-image snippets, size comparison.
- SVG SanitizerRemove scripts, event handlers, javascript: links, foreignObject and external references.
- SVG Path EditorInspect path commands, drag points and handles, convert absolute ↔ relative, round and minify.
- SVG Sprite GeneratorCombine icons into one <symbol> sprite with IDs from file names and a usage snippet.