SVG Viewer and Cleaner

View an SVG safely, strip scripts, event handlers and outside links, tidy away editor clutter, and copy it as a file, a data URI or a CSS background.

Preview

Paste an SVG or open a file.

SVG

SVG code

Runs in your browser — nothing you enter leaves this device.

About this tool

What it does

SVG Viewer and Cleaner shows an SVG drawing safely and prepares it for use on a website. An SVG is a text file that can contain more than a drawing: scripts, event handlers such as onload, links that fetch files from other sites, and embedded HTML. Pasted into a page as inline code, those can run. This tool removes all of them with DOMPurify’s SVG rules and lists what it took out, then shows the result as an image, which a browser never lets run code. An optional tidy step removes what drawing programs leave behind — Inkscape, Sketch, Illustrator and Figma metadata, editor attributes, empty groups and whitespace — which often makes icons noticeably smaller. You can then download the clean file, copy its code, or copy it as a data URI or a CSS background-image, escaped the short way.

How to use it
  1. Paste the SVG code, open an .svg file, or drop one on the box.
  2. Read what was removed for safety and what was tidied.
  3. Check the drawing on checks, a light or a dark background.
  4. Download the clean SVG, or copy it as code, a data URI or a CSS background.
Limits and your data
  • The tidy step does not rewrite path data or round numbers, so files exported with very long decimals stay larger than an aggressive optimiser would make them; nothing about the drawing changes.
  • Links to outside images and fonts are removed, so a drawing that relied on them will show without them. Embed images as data: URLs instead.
  • Animations written in SVG (SMIL) and CSS inside the file are kept; scripted animation is removed.
  • Files over 5 MB are refused; an SVG that large is usually an embedded photo and is better as a JPEG or WebP.
  • Width, height and viewBox are shown as written; an SVG without a viewBox cannot scale cleanly.
  • The file is read and cleaned in your browser; it is never uploaded.

Questions

Can an SVG contain a virus?

An SVG can contain JavaScript that runs when the file is opened in a browser or placed inline in a page. Cleaning removes scripts and event handlers; shown as an image, an SVG cannot run code at all.

How do I use an SVG as a CSS background?

Copy it as a CSS background and paste the line into your stylesheet. The SVG is written into the URL itself, so there is no extra file to load.

Is a data URI better than Base64 for SVG?

Usually yes: escaping only the few characters that need it keeps an SVG data URI around a quarter smaller than Base64, and it stays readable.

Why is my exported SVG so large?

Drawing programs add editor data, metadata and indentation. Turn on Tidy to remove it; the drawing itself is unchanged.