SVG Code to PNG, With a Live Playground

Paste SVG markup, watch it render as you type, then export a PNG at 1x, 2x, 3x or 4x on a transparent or solid background. The share link carries the code in the URL fragment, so a teammate opens exactly the canvas you saw — no upload, no account.

Paste & preview1x–4x PNGShare linkNo upload

Playground

Everything runs in this tab · nothing is posted
Preview appears here

Export

Scale
Exact widthpx — overrides the scale
Background
The code travels in the URL fragment (#s=), which browsers never send to a server. Long files make long links — the counter above warns past 8,000 characters.

Turning SVG code into a PNG is a two-stage job: parse the markup into a DOM, then ask the canvas to draw that DOM at the pixel size you choose. Both stages are visible here — the editor shows what the parser sees, the preview shows what the rasteriser produced, and the size readout tells you how many pixels actually came out.

Paste, preview, export: the loop

  1. Paste or load. Drop in markup from Figma, Illustrator, a design system or a chat message, or start from one of the five templates.
  2. Watch the preview. Rendering happens as you type, 250 ms after the last keystroke, so a syntax error shows up immediately with the line number instead of silently producing a blank canvas.
  3. Pick a scale. 1x is the SVG's own size, 2x doubles both dimensions, 4x quadruples them. An exact width overrides the scale when you need a fixed asset size.
  4. Export. The PNG is named svg-code-2x.png, or svg-code-512px.png when you set a width, so the file explains itself in a folder full of exports.
One SVG icon rendered at 1x, 2x and 4x PNG with the resulting pixel dimensions and file sizes, beside a share link strip carrying the code in the URL fragment
The same vector at 1x, 2x and 4x: pixel counts rise, shape count does not — and the share link carries the whole file. · swipe to see it all

What 1x to 4x actually changes

The scale multiplies output pixels, not vector detail. At 4x, the browser rasterises the shapes at four times the coordinates, so curves and hairlines are computed at that resolution and look genuinely crisp; no new shapes appear. That is the difference between this and upscaling: enlarging a 1x PNG invents pixels by interpolation, while a 4x export re-draws from the geometry. A 24 × 24 icon at 4x becomes a 96 × 96 PNG, four times wider and roughly four times the file size on a flat mark. Anything above 8,192 px per side is refused, because canvas memory grows with the square of the dimension and the tab starts to stall.

Share links that reproduce the exact canvas

The share button packs the code, the scale and the background into the URL fragment: …/svg-code-to-png.html#s=eyJjIjoi…. Fragments are handled entirely by the browser, so the SVG never leaves the machine — not even as a request log entry. Open the link and the playground restores the code, re-renders, and lands on the same pixels. Two practical limits: a very large SVG makes a very long URL (some chat clients wrap or truncate past roughly 8,000 characters, and the counter turns amber when that is close), and the fragment is not a version control system — if you need history, keep the file.

Why pasted SVG code renders blank

Four faults cover almost every blank canvas. Missing namespace: an <svg> without xmlns="http://www.w3.org/2000/svg" parses as unknown elements and draws nothing. Zero or percentage size: width="100%" with no viewBox leaves the rasteriser with no intrinsic size. Paint that resolves to nothing: fill="none" on a shape with no stroke, or a url(#gradient) whose id was stripped during copy. External references: a linked raster image, a webfont, or a CSS import — the browser sandboxes SVG loaded as an image and refuses to fetch any of them.

The SVG Validator reports all four with line numbers; the SVG to Code tool goes the other way and converts a working file into embeddable markup.

Sizing rules that keep exports sharp

When to ship the PNG and when to ship the SVG

A PNG is the safer default for anything that has to look identical everywhere: email signatures, chat avatars, app store screenshots, slide decks and print handoffs. It carries no code, no external references and no font assumptions, so it cannot be broken by a sanitizer or a CMS that strips SVG. The SVG is the better asset wherever the image has to scale or change colour: icons in a component library, logos on a responsive page, diagrams that must stay crisp at 4x.

In practice most teams keep both: the SVG as the source of truth, and a 2x PNG exported here as the fallback for the places that still refuse vector files. Export the PNG from the same markup you ship, not from a screenshot, so the two never drift apart.

Privacy and offline use

There is no upload endpoint on this page, no analytics call, and no external script. The code is parsed by DOMParser, drawn by the canvas API and encoded by the browser's own PNG writer. Disconnect the network and the playground still works — which is also the quickest way to verify that claim.

Frequently asked questions

Does a 4x export add detail to an SVG?

No. The vector is redrawn at four times the pixel size, so edges are computed at that resolution and stay crisp, but no new shapes appear: a 24 × 24 icon at 4x is a 96 × 96 bitmap of the same drawing. It looks sharper than an upscaled 1x PNG because the rasteriser works from the shapes, not from pixels.

Why is my pasted SVG blank?

Almost always one of four things: a missing xmlns, a width of 0 or 100% with no viewBox, a fill that resolves to nothing, or an external file the browser refuses to load inside an image. The error line under the editor names the parse fault; the size readout exposes the rest.

Is the SVG code sent anywhere when I share a link?

No. The code is packed into the URL fragment after the hash, and browsers never send that part to a server. Nothing is stored on svgvector.com.

Can I get a JPG or WebP instead of a PNG?

Not on this page — the canvas PNG writer is the only lossless path here. For WebP, GIF and BMP output use the SVG to WebP, BMP and GIF converter, and for a flattened JPG use SVG to JPG.

Related SVG workflows

More free SVG tools