Skip to content

SVG Viewer

✨ Preview updates as you type 0 lines · 0 B

Preview

100%
Background

Paste SVG code on the left

Or drop an .svg file here. The drawing shows up right away and changes as you type.
Nothing to show yet Need a PNG? Copy the code, then paste it into SVG to PNG.

SVG Viewer & Editor: View, Edit and Minify SVG Online

What Is an SVG Viewer?

It shows you what an SVG file looks like, and lets you change its code and see the result right away. Paste the code or open the file, and the drawing appears next to it. Zoom in to check a corner, put it on a dark background to see if your logo survives dark mode, then tidy or shrink the code and download it.

Everything runs in your browser. Your file isn’t uploaded, and the scripts an SVG can carry never run here (more on that below).

What an SVG Is

SVG stands for Scalable Vector Graphics. Instead of storing pixels like a PNG or JPG, it stores instructions, written as text: “a circle here, this big, filled yellow”. That’s why it stays sharp at any size, and why you can open it in a text editor and change it by hand.

A whole SVG file, three lines long

<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
  <circle cx="60" cy="60" r="45" fill="#facc15"/>
</svg>

That’s a yellow sun: a circle 45 units wide from its center, in the middle of a 120 × 120 canvas. Load it, then change #facc15 to #f97316 and it turns orange as you type.

Shapes and text together

<svg xmlns="http://www.w3.org/2000/svg" width="260" height="110" viewBox="0 0 260 110">
  <rect x="5" y="5" width="250" height="100" rx="14" fill="#fff" stroke="#e11d48" stroke-width="4"/>
  <rect x="5" y="5" width="250" height="34" rx="14" fill="#e11d48"/>
  <text x="130" y="29" fill="#fff" font-family="Arial, sans-serif" font-size="16" text-anchor="middle">HELLO, MY NAME IS</text>
  <text x="130" y="84" fill="#111827" font-family="Georgia, serif" font-size="34" text-anchor="middle">Sam</text>
</svg>

Each tag draws one thing, in order, so later ones sit on top. Here two rounded rectangles make the badge, and two <text> tags write on it. Swap “Sam” for your own name to try editing.

How to View and Edit an SVG File

Click Sample in the tool above to follow along with a potted plant.

Step 1 Open or Paste Your SVG

  • Drop the file anywhere on the tool, or click the upload button. Both .svg and .svgz work.
  • Paste the code if you copied it from a website, an icon set or a design app.
  • HTML with an <svg> inside is fine too. The tool finds the SVG and shows it.

Step 2 Zoom In and Out

Fit makes the drawing as big as the preview allows, so even a tiny 16 px icon fills the space. 100% shows it at its real size. The − and + buttons step through the zoom levels. On a computer, hold Ctrl (Cmd on a Mac) and scroll over the drawing; on a phone, pinch. Click the drawing first and the + and − keys work as well.

Step 3 Try Different Backgrounds

The checkerboard shows which parts are see-through. Switch to Dark to check a logo that will sit on a dark header, or pick Color and choose the exact color of your site. A black logo on a dark background is easy to miss until a visitor points it out.

Step 4 Edit the Code

Change anything on the left and the drawing updates a moment later. If you break something, say a missing quote, the last good drawing stays on screen but faded, and a red message names the line. Click Show line to jump straight to it.

Step 5 Tidy It, Shrink It, Save It

  • Format puts each tag on its own line with nested tags indented, so a one-line file becomes readable.
  • Minify does the opposite: it makes the file as small as it safely can (see below).
  • Both can be taken back with Undo, or Ctrl+Z in the editor.
  • .svg downloads the file and Copy code (the lime button) copies it.

What the viewBox Does

Think of the viewBox as a sheet of graph paper. viewBox="0 0 24 24" says: the drawing is made on a sheet 24 squares wide and 24 squares tall, starting at the top-left corner (0, 0). The width and height say how big to print that sheet on the screen.

One heart drawn on a 24 by 24 grid, shown at 24, 48 and 96 pixels viewBox="0 0 24 24" 0, 0 is the top-left corner 24 px 48 px 96 px
One drawing on a 24 × 24 grid. Change the width and height and it’s drawn bigger, with no blur.

Same viewBox, different size

<!-- Drawn 24 × 24 px -->
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">

<!-- Same drawing, 96 × 96 px and still sharp -->
<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96" viewBox="0 0 24 24">

Only the width and height changed. The shapes inside still use the 24-square grid, so nothing else needs editing. Turn on Grid in the tool to see those squares over your own drawing, and viewBox to outline the area it covers.

The first two numbers move the window

<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" viewBox="100 0 200 100">
  <!-- The viewBox starts at x = 100, so the blue circle is left out -->
  <rect width="300" height="100" fill="#e0f2fe"/>
  <circle cx="50" cy="50" r="35" fill="#0284c7"/>
  <circle cx="150" cy="50" r="35" fill="#f97316"/>
  <circle cx="250" cy="50" r="35" fill="#65a30d"/>
</svg>

The viewBox is a window onto the drawing. Here the window starts 100 units in, so the blue circle is outside it and you see only the orange and green ones. Load it and change 100 0 to 0 0 to slide the window back.

Cleaning Up SVGs From Design Apps

Illustrator, Inkscape, Figma and Sketch save more than the drawing. You get a comment saying which app made it, layer names, editor settings, and numbers like 32.000001. None of it changes what you see, but it can make the file two or three times bigger. Minify takes it out.

Minify removesMinify keeps
Comments, like <!-- Generator: Adobe Illustrator -->ids and classes, so your CSS and links still find them
<metadata> and app data (inkscape:, sodipodi:, Illustrator’s i:)<title> and <desc>, which screen readers use
Spaces and line breaks between tagsEvery space inside <text>
Extra decimals (it keeps 3 by default, more where the drawing needs them)The <style> rules, written shorter
Empty groups, and x="0px" y="0px" on the outer <svg>Scripts and links (left alone, never run)

Before and after

What Illustrator saved (273 bytes):

<!-- Generator: Adobe Illustrator 27.0, SVG Export Plug-In -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
     x="0px" y="0px" viewBox="0 0 64 64" xml:space="preserve">
<g>
  <circle cx="32.0000" cy="32.0000" r="24.5000" fill="#FF6347"/>
</g>
</svg>

After Minify (163 bytes), same circle:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="Layer_1" viewBox="0 0 64 64" xml:space="preserve"><circle cx="32" cy="32" r="24.5" fill="#ff6347"/></svg>

About Minify decimals: it’s the fewest decimals Minify keeps, 3 by default. Minify also looks at how big the drawing is, and never rounds a number by more than about 0.025% of the viewBox’s smaller side. So a 24 × 24 icon keeps at least 2 decimals even if you pick 0, while a 2000 × 2000 map can go down to whole numbers. Opacities, gradient stops and filter numbers keep at least 4 decimals, and a number that isn’t 0 never turns into 0.

At the default, typical icons look the same after Minify. Once in a while a sharp corner on a thick stroke changes shape by a pixel, because the browser decides whether to cut that corner off from the exact angle. Look at the preview after you minify, and click Undo if something moved.

Save yourself some of the work at export time, too. In Illustrator, use File > Export > Export As, pick SVG and set Styling to “Presentation Attributes”. In Inkscape, use Save As > Optimized SVG or Plain SVG instead of Inkscape SVG.

Why an SVG Shows Nothing, or Not What You Expected

When something looks wrong, the tool tells you above the preview if it spots one of these.

No width, height or viewBox

Browsers then draw a 300 × 150 px box and cut off the rest. Add a viewBox that covers the drawing, like viewBox="0 0 512 512".

Shapes outside the viewBox

Anything past the edge isn’t shown. Tick viewBox to see the outline, then move the shapes or widen the viewBox.

White on white

A white logo, or one with fill="none" and a white stroke, is invisible on white. The Dark background shows it at once.

Linked images and fonts

An <image href="photo.jpg"> or a web font lives in another file. When an SVG is shown as an image, browsers don’t load those, so they’re missing here and in an <img> tag on your site. Put the image inside the SVG as a data: URI, and turn text into paths in your design app.

currentColor comes out black

currentColor means “the text color around me”. On its own there’s nothing around it, so it’s black. Inline in your HTML, it follows your CSS.

A missing xmlns

Without xmlns="http://www.w3.org/2000/svg" on the <svg> tag, browsers won’t show the file as an image. The preview adds it for you, and Format writes it into your code.

Try it: a star that went missing

<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 100 100">
  <!-- This star was drawn at x = 150, past the right edge of the viewBox -->
  <polygon points="150,10 162,40 194,40 168,58 178,90 150,70 122,90 132,58 106,40 138,40" fill="#f59e0b"/>
</svg>

Load it and the preview is empty. Tick viewBox to see the 100 × 100 window; the star sits at x = 150, off to the right. Change the viewBox to 100 0 100 100 and the star appears.

Try it: an arrow icon that uses currentColor

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
  <path d="M5 12h14M13 6l6 6-6 6"/>
</svg>

It shows black, since on its own there’s no text color to borrow. It also has only a viewBox, so its real size is 24 × 24 px (click 100% to see how small that is). Replace currentColor with #4d7c0f to make it green.

Is It Safe to Open Any SVG?

An SVG is code, and it can carry JavaScript, which is why some sites won’t accept SVG uploads at all. This page never runs it. The drawing is always shown as an image, the same way <img src="file.svg"> shows it on a website, and in that mode browsers skip every script and never load anything from outside the file. You can still read and edit the script in the code. It won’t do anything here. Even if you right-click the preview and open it in a new tab, it has no access to this site or anything you saved here.

Try it: an SVG that tries to run a script

<svg xmlns="http://www.w3.org/2000/svg" width="160" height="160" onload="alert('Hi!')">
  <script>document.title = 'Changed by the SVG';</script>
  <circle cx="80" cy="80" r="60" fill="#8b5cf6"/>
</svg>

Opened straight in a browser tab, this would pop up “Hi!” and rename the tab. Load it here and you get a purple circle and a note that the scripts didn’t run. No pop-up.

Your code stays on your device. The page remembers only your settings (background, grid, viewBox outline and decimals) in this browser, never the SVG itself, so reloading the page starts empty. The zoom isn’t kept either: every new drawing starts at Fit.

Putting the SVG on a Web Page

There are two common ways, and they behave differently:

<!-- As a picture file: scripts never run, it's cached like any image -->
<img src="/images/logo.svg" alt="Bean There Coffee" width="160" height="40">

<!-- Pasted inline: CSS on your page can style it, currentColor follows your text -->
<a href="/" class="logo">
  <svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path d="M5 12h14" stroke="currentColor"/></svg>
  Home
</a>

Use <img> for logos and pictures: it’s simple, cached, and scripts can’t run. Paste the SVG inline for small icons you want to color with CSS. The HTML images tutorial covers alt text, sizes and centering.

What It Can’t Do

Related Tools

Frequently Asked Questions

How do I view an SVG file online?

Drop the .svg file on the tool, click the upload button, or paste the SVG code into the box on the left. The drawing shows up on the right straight away. Use Fit or 100% to change the zoom, and the background buttons to see it on white, dark or a checkerboard. The file is read in your browser and isn’t uploaded anywhere.

Can I edit the SVG code and see the changes?

Yes. The preview redraws a moment after you stop typing, so you can change a color like fill="#65a30d" to fill="#e11d48" and watch it happen. If you make a typo that breaks the code, the last good drawing stays on screen, faded, and a red message tells you which line to look at. When you’re done, Download saves it as an .svg file and Copy code puts it on your clipboard.

Why is my SVG blank or cut off?

The usual causes: the SVG has no viewBox, so browsers show only a 300 × 150 px corner of it; the shapes sit outside the viewBox; it uses currentColor or white shapes, which vanish on a white background; or it links to images and fonts in other files, which don’t load when an SVG is shown as an image. The tool lists what it spots above the preview. Turn on the viewBox outline and try the Dark background to check the first and third.

What does Minify remove, and will my drawing change?

It removes comments, metadata, the extra data design apps like Inkscape and Illustrator save for themselves, spaces between tags, and extra decimals. It also writes path data more compactly. It keeps ids, classes, titles and every bit of text. The decimals setting (3 by default) is the fewest it keeps: on a small viewBox like 0 0 24 24 it keeps at least 2 even if you pick 0, opacities, gradient stops and filter numbers keep at least 4, and a number that isn’t 0 never becomes 0. At the default, typical icons look the same. Once in a while a sharp corner on a thick stroke shifts by a pixel, so check the preview and click Undo if you don’t like it.

What is the viewBox in an SVG?

It’s the SVG’s own coordinate system. viewBox="0 0 24 24" means the drawing is made on a 24 × 24 grid. The width and height then decide how big that grid is drawn on the page, so the same icon can be 24 px or 240 px and stay sharp. Without a viewBox the drawing can’t scale, which is why icons without one often look cut off.

Is it safe to open an SVG from someone else?

Yes. SVG files can contain scripts, but this page only ever shows the drawing as an image, the same way an <img> tag on a website does. In that mode browsers never run the scripts and never load files from outside the SVG. You can read and edit the code, scripts included, without any of it running.

Can I open .svgz files?

Yes. An .svgz is just an SVG squeezed with gzip. The tool unzips it in your browser and shows the code, up to 5 MB of SVG. When you download, you get a normal .svg file.

Why does my icon show up black?

Icon sets often use fill="currentColor" or stroke="currentColor", which means “use the text color of the page around me”. Shown on its own as an image, there’s no page, so it’s black. Pasted straight into your HTML, it follows the CSS color of its parent. To give it a fixed color, replace currentColor with a color code like #4f46e5.

How do I turn the SVG into a PNG?

Copy the code with Copy code, then paste it into the SVG to PNG converter on this site. There you can pick the size, keep the background see-through or fill it, and download a PNG, JPG or WebP.