Skip to main content

Remove Metadata

Default

Removes the <metadata> element from the document.

Metadata doesn't effect rendering. From an optimization perspective, these can always be safely removed.

There may be cases you'd want to disable this plugin, as some SVGs include copyright and licensing information in the metadata. In particular, documents that reference the Creative Commons namespace.

info

You can learn more about referencing copyright and licensing on the SVG Tiny 1.2 specifications, or by reading The Creative Commons Rights Expression Language.

Usage

svgo.config.js
module.exports = {
plugins: [
"removeMetadata"
]
}

Demo

Live Editor
const svg = `
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox=" 0 0  150 100 " width="150">
  <!-- Created with love! -->
  <defs>
    <ellipse cx="50" cy="50.0" rx="50.00" ry="auto" fill="black" id="circle"/>
  </defs>
  <g>
    <use href="#circle" transform="skewX(16)"/>
    <rect id="useless" width="0" height="0" fill="#ff0000"/>
  </g>
</svg>
`;

const svgoConfig = {
  js2svg: { indent: 2, pretty: true },
  plugins: [
    "removeMetadata"
  ]
}

render(<SvgoPreview svg={svg} svgoConfig={svgoConfig}/>);
Result
Loading...

Implementation