Skip to main content

XML format

SVG

A vector image format that is genuine XML, and therefore both diffable and a security surface.

Because SVG is XML, an icon set can be searched, validated and version-diffed like any other document — a real advantage over binary image formats when you need to know what changed in a design system.

It is also the XML format most often accepted as a user upload, which makes it the one where XML's more dangerous features matter most: scripts, external references and entity expansion all travel inside a file that looks like an image.

Constraints that bite

  • A standalone .svg must declare the SVG namespace on its root or it will not render.
  • Inline SVG in HTML gets the namespace implicitly, so copy-pasting inline markup into a file often breaks it.
  • User-supplied SVG can carry <script>, external references and entity expansion — sanitise before serving.
  • .svgz is gzip-compressed SVG and must be served with Content-Encoding: gzip.
  • viewBox, not width/height, is what makes an SVG scale.
Root element
<svg>
Media type
image/svg+xml
Extensions
.svg, .svgz
Namespaces
  • http://www.w3.org/2000/svg
XMLDir label
xml

Specification: SVG 2

A minimal valid document

Every example on this site is checked against the same parser the workspace uses, so what you see below is known to be well-formed.

svg.xml
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  <path d="M4 12h16" stroke="currentColor" stroke-width="2" fill="none"/>
</svg>

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.