Skip to content

Remove XML Declaration Default

Removes the XML declaration from the document.

The SVG language is based on XML, and is XML compatible, so editors often include an XML declaration.

An XML declaration is the line at the top of an XML file to indicate document meta-data, like encoding and which version of the XML specifications it adheres to.

xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>

The XML declaration is optional in XML 1.0, but mandatory in the XML 1.1. If the XML declaration is omitted, the document is assumed to follow the XML 1.0 specifications, which won't impact SVG documents.

It can be safely removed without impacting compatibility.

Usage

js
module.exports = {
  plugins: ["removeXMLProcInst"],
};
module.exports = {
  plugins: ["removeXMLProcInst"],
};

Demo

Implementation

https://github.com/svg/svgo/blob/main/plugins/removeXMLProcInst.js