<span aria-hidden="true" id="what-is-an-svg-file-everything-you-need-to-know-about-the-svg-format"></span>

# What is an SVG file? Everything you need to know about the SVG format

An **SVG file** describes two-dimensional graphics with XML-based markup. Unlike JPEG or PNG, SVG is a vector format: it stores shapes, paths, text, gradients, and transforms rather than a fixed grid of pixels. A well-formed SVG can scale from an icon to a billboard without becoming blurry.

<span aria-hidden="true" id="how-does-svg-work"></span>

## How does SVG work?

An SVG document contains elements such as `<path>`, `<circle>`, `<text>`, and `<image>`. A browser or renderer interprets those instructions at the requested display size. CSS can style elements, and SVG can include links, filters, animation, scripts, or external resources.

That flexibility is powerful, but it means untrusted SVG uploads should be treated as active content rather than harmless pixels.

<span aria-hidden="true" id="benefits-of-svg"></span>

## Benefits of SVG

* **Resolution independence:** remains sharp at any size or pixel density.
* **Small geometric assets:** logos and icons can be smaller than raster equivalents.
* **Editable structure:** colors, text, and shapes can be changed without repainting pixels.
* **Accessible content:** meaningful titles and text can be represented in the document.
* **Animation and styling:** integrates with web layout and CSS.

<span aria-hidden="true" id="limitations-and-security-considerations"></span>

## Limitations and security considerations

SVG is inefficient for detailed photographs. Complex paths and effects can also be expensive to render. Because SVG may contain scripts, event handlers, links, and external references, do not inject an untrusted upload directly into an HTML document without sanitizing or rasterizing it.

Use PNG, WebP, or AVIF when you need a predictable pixel image or a safe delivery derivative.

<span aria-hidden="true" id="svg-compared-with-png"></span>

## SVG compared with PNG

|Format|Best fit|Scaling|Content model|
|-|-|-|-|
|SVG|Logos, icons, diagrams, illustrations|Lossless at any size|XML vector instructions|
|PNG|Screenshots and pixel art|Resampling required|Fixed raster pixels|

<span aria-hidden="true" id="how-to-rasterize-svg-files-with-transloadit"></span>

## How to rasterize SVG files with Transloadit

[🤖/image/resize](/docs/robots/image-resize.md) can render an uploaded SVG into a predictable PNG at the dimensions your product needs:

```json
{
  "steps": {
    ":original": { "robot": "/upload/handle" },
    "png": {
      "use": ":original",
      "robot": "/image/resize",
      "format": "png",
      "width": 1200,
      "height": 1200,
      "resize_strategy": "fit"
    }
  }
}

```

<span aria-hidden="true" id="svg-faq"></span>

## SVG FAQ

<span aria-hidden="true" id="is-svg-an-image-format-or-a-document-format"></span>

### Is SVG an image format or a document format?

It is an image format represented as an XML document. That document structure is why SVG can include more behavior than a raster image.

<span aria-hidden="true" id="can-svg-contain-javascript"></span>

### Can SVG contain JavaScript?

Yes. SVG can contain active content, so sanitize or rasterize uploads before embedding untrusted SVG inside a page.

<span aria-hidden="true" id="should-photographs-be-converted-to-svg"></span>

### Should photographs be converted to SVG?

No. SVG is suited to shapes and illustrations. Use JPEG, WebP, or AVIF for photographic content.

<span aria-hidden="true" id="related-demos"></span>

## Related demos

* [Convert SVG to JPEG](/demos/image-processing/convert-an-image-from-svg-to-jpg.md)
* [Resize an image for a Twitter cover](/demos/image-processing/resize-to-twitter-cover-dimensions.md)
* [Watermark an image](/demos/image-processing/image-watermarking.md)
