SVG safety
Safe SVG sanitizer
A safe SVG sanitizer removes risky markup before you paste, embed, or convert an SVG. It is the right first step for unknown SVG files.
SVG is code, not only an image format. A safe SVG sanitizer should remove script tags, event handlers, external JavaScript links, unsupported tags, and markup that can create browser or app problems. PDFSVG does this locally in your browser for everyday SVG cleanup.
What a safe SVG sanitizer should remove
| Risky SVG item | Why it matters |
|---|---|
<script> | Can run JavaScript in places that allow active SVG. |
| Event handlers | Attributes like onclick can attach behavior to SVG elements. |
| Unsafe links | External or JavaScript links can send users somewhere unexpected. |
| Unsupported tags | Some tags do not belong in a simple web icon or app asset. |
When to sanitize SVG
Sanitize SVG before pasting unknown markup into a site, converting SVG to React, making a data URI, or sending an SVG to another person. If you trust the source and only need a smaller file, minification may be enough. For unknown files, clean first.
What sanitizer tools cannot promise
A browser sanitizer can remove common risky markup, but it is not a complete security policy for user uploads in a production app. If your app accepts SVG uploads from users, handle storage, serving headers, content type, and server-side validation separately.
Local cleanup is better for private files
For everyday SVG files, local cleanup avoids sending the source file to a conversion server. The SVG cleaner runs in the browser, shows the cleaned output, and lets you copy or download the result.
Common questions
What is a safe SVG sanitizer?
A safe SVG sanitizer removes risky SVG markup such as scripts, event handlers, unsafe links, and unsupported tags before the SVG is used in a page or app.
Can an SVG file contain JavaScript?
Yes. SVG can contain script tags, event handlers, and links. That is why unknown SVG files should be cleaned before publishing or embedding.
Does the PDFSVG sanitizer upload my SVG?
No. The SVG cleaner runs in the browser for local cleanup, preview, copy, and download.
Is SVG sanitizing the same as minifying?
No. Sanitizing removes risky or unsupported markup. Minifying reduces file size after the SVG already looks correct.