A logo saved as a PNG gets bigger every time you ask for more pixels, while the same logo saved as SVG can keep nearly the same file size at any display size. The reason is what each file stores. A raster image stores a grid of colored pixels. A vector image stores instructions for drawing shapes, so its size follows the number of shapes and not the number of pixels.
This guide compares the two approaches, counts the bytes of a real SVG, shows the point where a vector file stops being small, and ends with rules for choosing between them.
Two ways to describe a picture
A raster image is a grid. The federal digitization guide describes raster data as a grid in which each cell is called a pixel, and the data recorded for each pixel is expressed as its bit depth. Double the width and height and the grid holds four times the cells, so the uncompressed size grows fourfold. The image file size calculator applies this rule: bytes = width × height × bits per pixel ÷ 8.
SVG, defined by the W3C, is a language based on XML for describing two-dimensional vector and mixed vector and raster graphics. It allows three types of graphic objects: vector shapes, images and text. The specification describes SVG content as scalable to different display resolutions.
| Raster (JPEG, PNG) | Vector (SVG) | |
|---|---|---|
| What is stored | A grid of pixel values | Shapes, paths, text and styles as markup |
| What drives file size | Pixel count and bits per pixel, then compression | Number of shapes and the length of their path data |
| Scaling up | Needs more pixels or looks coarse | Redrawn from the instructions at the new size |
| Strong at | Photographs and continuous tone | Icons, logos, diagrams, interface elements |
| Weak at | Staying small at large dimensions | Photographic detail |
The format guide from a web-platform reference matches this table: SVG is ideal for interface elements, icons and diagrams that must be drawn accurately at different sizes, and it is not generally useful for strictly bitmap or photographic images.
Why an SVG file's size follows the number of shapes
SVG describes shapes with elements such as rect, circle, ellipse, line, polyline and polygon. Mathematically, the specification says each of these is equivalent to a path, which represents the outline of a shape that can be filled or stroked. A path is written as commands such as moveto, lineto and curveto, each followed by coordinates.
Every shape is a short piece of text, so more shapes mean more text. Pixel dimensions only appear as a few numbers.
Here is a complete SVG file:
xml
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="40" fill="red"/></svg>
Worked example. Example: one red circle in a 100 × 100 drawing, then the same circle in a 1000 × 1000 drawing.
- The file above is 114 bytes when written as plain text, counting each character as one byte.
- For the 1000 × 1000 version, the numbers become
width="1000" height="1000",cx="500" cy="500"andr="400". The file is 119 bytes. Five extra digits are the whole difference. - A raster version at 24 bits per pixel is 100 × 100 × 24 ÷ 8 = 30,000 bytes uncompressed at the small size, and 1,000 × 1,000 × 24 ÷ 8 = 3,000,000 bytes at the large one.
- The raster grew 100 times because it has 100 times as many pixels. The vector grew by 5 bytes.
The byte counts are for this exact text, counted by a script. A real file can contain more markup than this minimal example, so measure your own. The raster figures are uncompressed, as covered in how big is an uncompressed image.
Counting shapes: when a vector stops being small
Estimate an SVG with size ≈ wrapper + shapes × bytes per shape. In the example the wrapper (the svg start and end tags) is 71 bytes and each circle element is 43 bytes.
| Shapes in the file | Calculation | Size |
|---|---|---|
| 1 | 71 + 1 × 43 | 114 bytes |
| 10 | 71 + 10 × 43 | 501 bytes |
| 100 | 71 + 100 × 43 | 4,371 bytes |
| 1,000 | 71 + 1,000 × 43 | 43,071 bytes |
Example: a file with 1,000 such circles is 43,071 bytes, which is 1.4% of the 3,000,000-byte raster at 1000 × 1000. The two reach the same size at (3,000,000 − 71) ÷ 43 = 69,766 shapes. That comparison is generous to the vector, because a compressed bitmap is smaller than its raw size, so in practice the crossover comes sooner. A traced photograph generally needs a huge number of tiny shapes, so a vector copy of a photo is often not small at all.
The format guide adds that SVG source may be compressed in transit with HTTP compression or stored on disk as an .svgz file. See HTTP compression: gzip and Brotli for how that works.
When a bitmap hides inside a vector file
SVG has an image element that can refer to raster files such as PNG or JPEG. The bitmap keeps its own pixels and its own size. Wrapping a photograph in an SVG file does not turn it into a vector, and the file is not small just because it carries the .svg name.
Remember also that a screen always draws pixels. A vector file is turned into pixels at the size where it is displayed. The file stays small, but the picture on screen still has a pixel count, covered in choosing image dimensions for the web.
Choose with these rules:
- Flat shapes, text and icons that must stay sharp at any size: SVG.
- Photographs and continuous tone: a raster format, as discussed in JPEG vs. PNG.
- A drawing with thousands of tiny shapes: test both and compare the real sizes.
Common mistakes
- Assuming every SVG is tiny. Size follows shape count and path data length. A detailed illustration with thousands of paths can be large.
- Converting a photograph to SVG for scaling. A photo has no clean outlines. Tracing it produces very many shapes, and the result rarely looks the same.
- Embedding a bitmap in an SVG and calling it a vector. The embedded raster keeps its pixel count, so the file size follows the bitmap.
- Comparing against the wrong raster size. An uncompressed raster is a ceiling. Compare against the compressed file you would really use.
- Expecting a vector to have no size on a page. An SVG without width and height has no intrinsic dimensions, so the page must give it a size.
- Forgetting that pixels still exist at display time. The file is resolution-independent, but the screen shows a grid.
FAQ
Are SVG files always smaller than PNG files?
No. For a few simple shapes an SVG can be far smaller, as the byte counts above show. As the shape count rises, the SVG grows with it, while a PNG grows with its pixels. Test both when the drawing is complex.
Can SVG store photographs?
It can reference or contain bitmap images, but the format guide says SVG is not generally useful for photographic images. A raster format is the usual choice for photos.
Why does an SVG look sharp at any size?
Because it is redrawn from shapes and coordinates at each display size. The specification describes SVG content as scalable to different display resolutions.
What does raster mean?
A raster image is a grid of pixels, each with a stored color value. JPEG and PNG are raster formats.
Sources
- W3C, Scalable Vector Graphics (SVG) 2. Accessed November 6, 2026.
- W3C, Basic Shapes — SVG 2. Accessed November 6, 2026.
- W3C, Paths — SVG 2. Accessed November 6, 2026.
- W3C, Embedded Content — SVG 2. Accessed November 6, 2026.
- Mozilla (MDN Web Docs), Image file type and format guide. Accessed November 6, 2026.
- Mozilla (MDN Web Docs), <img> HTML image embed element. Accessed November 6, 2026.
- Federal Agencies Digital Guidelines Initiative (FADGI), Technical Guidelines for Digitizing Cultural Heritage Materials: Third Edition. Accessed November 6, 2026.



