Skip to content
DoItJag

SVG Code Previewer

See what SVG code draws before you put it in a page. Paste the code from an icon set, a design tool or a file, and the drawing appears at once on a chequered, white or dark background. The page reports the size and viewBox, points to the line of any XML error, and gives the SVG as a data URI for CSS.

About the SVG Code Previewer

SVG is a picture written as text: shapes, paths and colours described in XML. That makes it easy to copy from an icon library or a design tool’s export panel, but impossible to judge by reading. Paste the code here and the drawing appears at once.

Reading the result

Under the drawing the page reports its natural size and where that size came from. When width and height attributes are present, they decide it. When only a viewBox is given, its width and height are used. With neither, browsers fall back to 300 by 150 pixels, rarely what you meant. A drawing without a viewBox does not scale cleanly when you change its size in CSS, so the page warns you about that.

Worked example

Press Try an example to see a small landscape with a sky gradient, a sun and green hills. Now delete the closing slash from the rect line, the one that draws the background. The preview disappears and a message gives the line and column where the XML stopped making sense. Put the slash back and the drawing returns.

Backgrounds and zoom

Icons are often black on a transparent background and vanish against a dark page. The chequered background shows transparent areas; switch to Dark to check that a light icon is still visible. The zoom slider redraws the vector at the new size, so edges stay sharp even at 800%.

Safety

The drawing is displayed the same way a web page displays an SVG image. In that mode browsers never run scripts and never load linked pictures or fonts. If your code contains any of these, a note says so, because they will also be ignored wherever the file is used as an image.

Using the output

Copy as data URI gives a single line you can paste into CSS or an img tag. It escapes only the characters that need it, which is usually shorter than Base64. For a bitmap, the Convert to PNG button opens the SVG to PNG converter.

How to use SVG Code Previewer

  1. Paste the SVG code (or press Try an example).
  2. Check the drawing; zoom in and change the background to see transparent areas.
  3. Download it as an .svg file, copy it as a data URI or CSS background, or convert it to PNG.

Privacy: how it works

Everything happens in your browser. Your code is not sent to any server.

Frequently asked questions

Why is nothing shown for my code?

The code must be valid XML with an svg element that has xmlns="http://www.w3.org/2000/svg". The page shows the line and column of the first XML error, such as a tag that is not closed.

Do scripts or linked images in the SVG run?

No. The drawing is shown the way a web page shows an SVG image, so scripts never run and linked images or fonts are not loaded. The page tells you if the code contains them.

What is the data URI for?

It puts the whole SVG into one line you can use in CSS (background-image) or an img tag, so no separate file is needed. It is usually smaller than a Base64 version.