Before publishing SVG on a website
Remove scripts, event handlers, unsafe links, external JavaScript, embedded HTML, and tags your site does not need. If users can upload SVG to your app, add server-side validation too.
SVG cleanup workflow
Clean unknown SVG before you publish it, convert it to React, minify it, or encode it as a data URI. This checklist keeps the review practical.
A good SVG cleanup pass removes risky markup, checks that the image still previews correctly, and leaves the file ready for its next use. Clean first when the SVG came from a design export, icon marketplace, CMS, email, or pasted web snippet.
| Check | What to look for | Why it matters |
|---|---|---|
| Scripts and events | <script>, onclick, onload, other event attributes | They can add behavior you do not want in a site or app. |
| Links and references | javascript: links, external hrefs, linked images, remote fonts | They can break rendering, leak requests, or send users elsewhere. |
| IDs and paint servers | Gradients, masks, clip paths, filters, and url(#id) references | Broken IDs can make gradients disappear or turn artwork black. |
| ViewBox and dimensions | Missing viewBox, strange width or height, unwanted whitespace | Bad dimensions make export, alignment, and React sizing harder. |
| Preview after cleanup | Compare the cleaned SVG with the expected visual result | Cleaning can change complex SVG that depends on unsupported markup. |
Remove scripts, event handlers, unsafe links, external JavaScript, embedded HTML, and tags your site does not need. If users can upload SVG to your app, add server-side validation too.
Clean noisy export markup, then review JSX attribute names, duplicate IDs, currentColor, title, desc, and aria labels.
Make sure the cleaned SVG previews correctly. Minification is easier to trust after the safety and compatibility check is done.
Use small, cleaned SVG. Avoid large illustrations and files that people will need to edit or cache separately.
Keep the original file, preview the SVG, check for gradients or masks, and decide whether the cleaned SVG will be published, converted to React, minified, exported, or encoded as a data URI.
A cleanup pass should remove script tags, event handlers, unsafe links, unsupported tags, risky external references, and markup that does not belong in the intended use.
Yes for unknown SVG or design exports. Clean first, preview the result, then minify when the SVG already looks correct and you need a smaller file.
Yes. Cleaning removes risky or noisy markup before JSX conversion, then you can review IDs, labels, props, and accessibility decisions in the React component.