Friday, November 6, 2026 · Asia/KarachiFree tools · No signup · Runs in your browser

SVG to PNG

icon-40x20.svg declares width 40 and height 20 and fills that rectangle with #cc2222. The PNG is 40 by 20. A pixel near the corner reads about 204, 34, 34, which is that red after the browser paints the SVG. createImageBitmap would not decode this file. The page loads it as an image and then draws that image. The width and height attributes are required. An SVG that only uses a viewBox and no pixel size can come out at 0, and the page refuses that instead of inventing a size.

New

The SVG must declare width and height. This does not trace a photo back into vectors. Scripts inside an SVG are not a feature this page tries to run.

How to use

  1. Open icon-40x20.svg.
  2. Expect a 40 by 20 PNG.
  3. Expect the corner to be the red declared as #cc2222, near 204, 34, 34.

Formula / how it works

icon-40x20.svg declares width 40 and height 20 and fills that rectangle with #cc2222. The PNG is 40 by 20. A pixel near the corner reads about 204, 34, 34, which is that red after the browser paints the SVG. createImageBitmap would not decode this file. The page loads it as an image and then draws that image. The width and height attributes are required. An SVG that only uses a viewBox and no pixel size can come out at 0, and the page refuses that instead of inventing a size.

This is a rasteriser, not a tracer. A photo will not become vectors here, and vectors in the SVG become pixels at the size the file states. A script inside an SVG is not something this page tries to execute as a feature. The sample is a rectangle.

Use SVG to JPG only if you add that path later. This page stops at PNG so the flat red is not JPEG-blocked.

icon-40x20.svg says 40 by 20 and fills that rectangle with #cc2222. The PNG is 40 by 20, and a corner pixel is about 204, 34, 34 after the browser paints it. createImageBitmap refused this file, so the page loads the SVG as an image and draws that. An SVG with only a viewBox and no pixel size can measure as 0 and is refused rather than given an invented size. This does not trace a photograph into vectors, and it does not treat a script inside an SVG as a feature to run. The sample is a rectangle.

40 by 20 is not a guess. It is the width and height on icon-40x20.svg. The corner near 204, 34, 34 is the fill #cc2222 after painting. A file that only has a viewBox is refused when the measured size is 0, rather than stretched to a default the page invented. A photograph dropped on this control is the wrong input. Vectors become pixels here. Pixels do not become vectors. The rectangle sample has no script to run.

Forty by twenty is the size written on the SVG, and the PNG matches it. The corner near 204, 34, 34 is #cc2222 after painting. A viewBox without pixel width can measure as zero and is refused. The page does not invent a size. It also does not trace a photo, and it does not run a script that an SVG might contain. The sample is a red rectangle. A different drawing will not share that corner colour.

Keep the SVG. The PNG is 40 by 20 pixels of the red rectangle, and editing the vector later is much easier than editing those pixels. A corner near 204, 34, 34 checks the fill. A zero-size SVG is refused. A photo is the wrong input. Vectors become pixels at the size the file states, and that is the whole job.

A photo that is already pixels can be resized with image resizer. This page does not trace it.

Worked examples

Red rectangle SVG

Inputs: s2n-f: icon-40x20.svg

On this page, take icon-40x20.svg and press Convert to PNG. The SVG needs width and height in pixels.

Result: SVG to PNG: 40×20. 0.1 KB

Red rectangle SVG again

Inputs: s2n-f: icon-40x20.svg

On this page, take icon-40x20.svg and press Convert to PNG. The SVG needs width and height in pixels.

Result: SVG to PNG: 40×20. 0.1 KB

Use cases

  • Rasterising a rectangle SVG at its stated size.
  • Refusing an SVG that has no pixel width.
  • Not tracing a photo into vectors.
  • Not running a script that might be inside an SVG.

Tips & limitations

  • Width and height attributes are required.
  • viewBox alone can measure as 0 and is refused.
  • This is pixels, not a new SVG.
  • The sample is a flat red rectangle, not a photograph.

FAQ

Why is the PNG 40 by 20?

icon-40x20.svg says width 40 and height 20, and the page uses those pixels.

What colour is the corner?

About 204, 34, 34, from the fill #cc2222 after the browser paints the SVG.

Why not createImageBitmap on the file directly?

This Chrome would not decode the SVG that way. The page loads it as an image, then draws it.

Does this trace a photo?

No. Vectors become pixels. A photo does not become vectors.

What if the SVG has no width?

The page refuses a zero size instead of inventing one.

Is a script inside the SVG executed as a feature?

No. The sample is a rectangle. Do not rely on this page to run SVG scripts.

40 by 20 and the red corner describe icon-40x20.svg. An SVG without width and height is refused.