How to Extract Metadata from SVG Vector Files
SVG files store metadata as XML elements and attributes, including title, desc, Dublin Core RDF blocks, viewBox dimensions, and editor-specific namespaces from tools like Inkscape and Adobe Illustrator. This guide covers where that metadata lives, how to extract it with command-line tools, Python, and JavaScript, and how to manage SVG metadata across large asset libraries.
What Metadata Lives Inside SVG Files
SVG is an XML-based vector image format, which means its metadata is embedded directly in the file as readable text. Unlike binary image formats where metadata hides in encoded headers, SVG metadata sits in plain XML elements and attributes you can open in any text editor.
SVG files can contain several distinct categories of metadata:
- Descriptive elements: The
<title>and<desc>tags provide human-readable names and descriptions for the entire image or individual elements within it - The
<metadata>element: A dedicated container for structured metadata, typically holding Dublin Core properties wrapped in RDF/XML - Root attributes: The
<svg>root element carriesviewBox,width,height,xmlnsdeclarations, and version information - Editor namespaces: Tools like Inkscape add
inkscape:*andsodipodi:*attributes, while Adobe Illustrator embeds its owni:*andx:xmpmetablocks - Embedded resources: Font references via
@font-faceor<font>elements, linked images through<image>tags, and script references
A single SVG file exported from Inkscape might contain the document title, a description, the author's name in Dublin Core format, the Inkscape version, layer names, grid settings, and named views for different zoom levels. An SVG exported from Illustrator often includes XMP metadata with creation dates, modification timestamps, and color profile information.
Over 65% of all websites now use SVG for icons, logos, and illustrations according to W3Techs. That widespread adoption means web developers, designers, and asset managers regularly need to read, extract, or clean this metadata for accessibility audits, SEO optimization, license tracking, and file size reduction. For design teams managing SVG libraries at scale, Fastio's workspaces add collaboration and AI-powered metadata extraction to your asset stack.
How SVG Metadata Is Structured
Understanding the XML structure of an SVG file makes extraction straightforward. Here is a typical SVG with metadata from multiple sources:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
viewBox="0 0 800 600"
width="800" height="600"
version="1.1">
<title>Company Logo</title>
<desc>Primary brand logo for use on light backgrounds</desc>
<metadata>
<rdf:RDF>
<rdf:Description>
<dc:title>Company Logo</dc:title>
<dc:creator>Design Team</dc:creator>
<dc:rights>Copyright 2026 Example Corp</dc:rights>
<dc:date>2026-03-15</dc:date>
</rdf:Description>
</rdf:RDF>
</metadata>
<sodipodi:namedview inkscape:window-width="1920"
inkscape:window-height="1080"
inkscape:zoom="1.5"/>
<!-- graphic elements below -->
</svg>
The Three Metadata Layers
Layer 1: Root attributes. The <svg> element itself carries the viewBox (coordinate system), width and height (display dimensions), version, and all namespace declarations. The viewBox="0 0 800 600" tells you the internal coordinate space is 800 units wide and 600 units tall.
Layer 2: Descriptive elements. The <title> and <desc> elements can appear as children of the root <svg> or as children of individual shapes and groups. Browsers use <title> for tooltips, and screen readers use both elements for accessibility. The SVG specification allows multiple <title> and <desc> elements throughout the document, each describing its parent element.
Layer 3: The <metadata> block. This is where structured metadata lives. The W3C SVG specification recommends placing at most one <metadata> element per parent, and it should appear before other child elements. Inside, you will typically find Dublin Core properties wrapped in RDF/XML, though any XML namespace is allowed. Creative Commons license information, XMP data, and custom application metadata all belong here.
Extracting SVG Metadata with Command-Line Tools
Since SVG is plain XML, you can extract metadata without specialized image processing software. Standard XML tools work well, and ExifTool handles SVG as a supported format.
ExifTool
ExifTool reads SVG metadata out of the box. It parses the XML structure and returns title, description, viewBox dimensions, and any XMP or Dublin Core data it finds.
exiftool logo.svg
This outputs fields like SVG Version, Image Width, Image Height, View Box, Title, Description, and any XMP metadata present. For batch extraction across a directory:
exiftool -csv -r ./svg-assets/ > svg-metadata.csv
The -csv flag produces tabular output suitable for spreadsheets, and -r recurses into subdirectories.
xmllint and xmlstarlet
For precise extraction of specific elements, XML command-line tools give you full XPath control.
Extract the title element with xmllint:
xmllint --xpath "//*[local-name()='title']/text()" logo.svg
Extract Dublin Core metadata with xmlstarlet:
xmlstarlet sel -N dc="http://purl.org/dc/elements/1.1/" \
-t -v "//dc:creator" -n \
-t -v "//dc:rights" -n \
logo.svg
Extract the viewBox attribute:
xmlstarlet sel -t -v "//*[local-name()='svg']/@viewBox" logo.svg
These tools are available on most Linux distributions and through Homebrew on macOS. They handle namespace-aware queries that simple text tools like grep would struggle with, especially when the same namespace prefix maps to different URIs across files.
grep for Quick Checks
When you just need a fast sanity check, grep can pull out common metadata patterns:
grep -oP '(?<=<title>).*(?=</title>)' logo.svg
grep -oP 'viewBox="[^"]*"' logo.svg
This breaks on multi-line elements and namespace-prefixed tags, so use it only for quick spot checks, not production pipelines.
Manage SVG Metadata Across Your Asset Library
Upload SVG files to a Fastio workspace, extract metadata into a searchable spreadsheet with Metadata Views, and keep your team's asset catalog organized. generous storage, no credit card required.
Extracting SVG Metadata with Python
Python's XML libraries make SVG metadata extraction easy to script and automate. The standard library's xml.etree.ElementTree handles simple cases, while lxml provides full XPath 1.0 support and better namespace handling.
Basic Extraction with ElementTree
import xml.etree.ElementTree as ET
tree = ET.parse("logo.svg")
root = tree.getroot()
### SVG namespace
ns = {"svg": "http://www.w3.org/2000/svg",
"dc": "http://purl.org/dc/elements/1.1/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}
### Root attributes
viewbox = root.get("viewBox")
width = root.get("width")
height = root.get("height")
print(f"viewBox: {viewbox}, width: {width}, height: {height}")
### Title and description
title = root.find("svg:title", ns)
desc = root.find("svg:desc", ns)
print(f"Title: {title.text if title is not None else 'None'}")
print(f"Description: {desc.text if desc is not None else 'None'}")
### Dublin Core from metadata block
creator = root.find(".//dc:creator", ns)
rights = root.find(".//dc:rights", ns)
if creator is not None:
print(f"Creator: {creator.text}")
if rights is not None:
print(f"Rights: {rights.text}")
Batch Processing with lxml
For processing hundreds or thousands of SVG files, lxml is faster and handles malformed XML more gracefully:
from lxml import etree
from pathlib import Path
import csv
NS = {"svg": "http://www.w3.org/2000/svg",
"dc": "http://purl.org/dc/elements/1.1/",
"inkscape": "http://www.inkscape.org/namespaces/inkscape"}
def extract_svg_metadata(filepath):
tree = etree.parse(str(filepath))
root = tree.getroot()
def text_or_none(xpath):
result = root.xpath(xpath, namespaces=NS)
return result[0].text if result else None
return {
"file": filepath.name,
"viewBox": root.get("viewBox"),
"width": root.get("width"),
"height": root.get("height"),
"title": text_or_none("//svg:title"),
"description": text_or_none("//svg:desc"),
"creator": text_or_none("//dc:creator"),
"rights": text_or_none("//dc:rights"),
"inkscape_version": root.get(
f"{{{NS['inkscape']}}}version"
),
}
svg_files = Path("./assets").glob("**/*.svg")
rows = [extract_svg_metadata(f) for f in svg_files]
with open("svg_metadata.csv", "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=rows[0].keys())
writer.writeheader()
writer.writerows(rows)
This script walks a directory tree, extracts metadata from every SVG it finds, and writes a CSV report. The namespace-aware XPath queries handle files from Inkscape, Illustrator, Figma, and plain SVG exports without modification.
Handling Editor-Specific Namespaces
Different design tools embed different metadata. Inkscape uses sodipodi:* for page settings and inkscape:* for layer labels, zoom levels, and grid configurations. Adobe Illustrator wraps XMP metadata in x:xmpmeta blocks. Figma exports tend to be minimal, carrying just the root attributes and graphic elements.
To extract Inkscape layer names:
layers = root.xpath(
"//svg:g[@inkscape:groupmode='layer']/@inkscape:label",
namespaces=NS
)
print(f"Layers: {layers}")
To find all namespace URIs in an SVG (useful for identifying which tool created it):
for prefix, uri in root.nsmap.items():
print(f"{prefix}: {uri}")
Extracting SVG Metadata with JavaScript
JavaScript handles SVG metadata extraction both in the browser and in Node.js. Since browsers natively parse SVG as part of the DOM, client-side extraction requires no external libraries.
Browser-Side Extraction
async function extractSvgMetadata(url) {
const response = await fetch(url);
const text = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(text, "image/svg+xml");
const svg = doc.documentElement;
return {
viewBox: svg.getAttribute("viewBox"),
width: svg.getAttribute("width"),
height: svg.getAttribute("height"),
title: doc.querySelector("title")?.textContent,
description: doc.querySelector("desc")?.textContent,
};
}
The DOMParser approach works for SVG files loaded from the same origin or from CORS-enabled servers. For SVGs already embedded in the page as inline <svg> elements, you can query them directly with document.querySelector.
Node.js Extraction
For server-side or build-step extraction, libraries like fast-xml-parser or cheerio parse SVG files without a browser DOM:
import { XMLParser } from "fast-xml-parser";
import { readFileSync } from "fs";
const parser = new XMLParser({
ignoreAttributes: false,
attributeNamePrefix: "@_",
});
const svg = readFileSync("logo.svg", "utf-8");
const parsed = parser.parse(svg);
const root = parsed.svg;
console.log("viewBox:", root["@_viewBox"]);
console.log("Title:", root.title);
console.log("Description:", root.desc);
For build systems that process SVG assets (icon sprite generators, design token extractors, accessibility linters), these Node.js approaches integrate cleanly into existing toolchains without adding heavy dependencies.
Extracting Metadata from SVG Sprites
Many web projects bundle icons into a single SVG sprite file using <symbol> elements. Each symbol can carry its own <title> and <desc>:
const symbols = doc.querySelectorAll("symbol");
for (const sym of symbols) {
console.log({
id: sym.getAttribute("id"),
viewBox: sym.getAttribute("viewBox"),
title: sym.querySelector("title")?.textContent,
desc: sym.querySelector("desc")?.textContent,
});
}
This is particularly useful for accessibility audits. Each icon in a sprite sheet should have a <title> for screen readers, and extracting the current state tells you which ones are missing.
Removing and Cleaning SVG Metadata
SVG metadata adds file size and can leak information you do not want published. Editor-specific namespaces from Inkscape and Illustrator often double the file size without any visual effect. Before deploying SVG assets to production, cleaning metadata is standard practice.
SVGO (SVG Optimizer)
SVGO is the most widely used tool for cleaning SVG files. It removes editor metadata, collapses redundant groups, and optimizes path data:
npx svgo input.svg -o output.svg
SVGO's default configuration removes <metadata> elements, editor namespaces, comments, and unused namespace declarations. You can customize which plugins run. To keep <title> and <desc> for accessibility while removing everything else:
npx svgo input.svg -o output.svg \
--config='{"plugins":[{"name":"preset-default","params":{"overrides":{"removeTitle":false,"removeDesc":false}}}]}'
Inkscape's "Save as Plain SVG"
Inkscape can strip its own metadata through File > Save As > Plain SVG. This removes sodipodi:* attributes, inkscape:* attributes, and the <sodipodi:namedview> element. It preserves the <title>, <desc>, and <metadata> elements since those are part of the SVG specification.
ExifTool for Metadata Removal
ExifTool can strip metadata while preserving the visual content:
exiftool -all= output.svg
This removes XMP, Dublin Core, and other embedded metadata blocks. The graphic elements remain unchanged.
Privacy Considerations
SVG files from design tools can contain information you might not expect to share:
- Author names and emails in Dublin Core metadata
- File paths in linked image references (e.g.,
/Users/designer/Desktop/texture.png) - Font names that reveal your design system
- Creation and modification timestamps
- Inkscape grid and guide settings that show your design process
Run exiftool -v2 file.svg to see a detailed dump of everything embedded before sharing SVG files publicly.
Managing SVG Metadata Across Large Asset Libraries
When you manage hundreds or thousands of SVG files, individual extraction is not practical. You need a system that indexes metadata, tracks changes, and makes the data searchable.
Building a Metadata Index
The Python batch script from the earlier section is a starting point, but a proper asset pipeline needs persistent storage, change detection, and search. A common approach is to extract metadata on import and store it in a database or structured file that your asset management system queries.
For teams that need structured extraction without building custom pipelines, Fastio's Metadata Views automate this process. Upload SVG files to a workspace, describe the fields you want extracted in plain language (such as "title," "creator," "viewBox dimensions," and "license"), and the system populates a sortable, filterable spreadsheet. You can add new extraction columns later without reprocessing existing files.
This approach works well alongside local tools. Use SVGO to clean SVGs before deployment, ExifTool or Python scripts for pre-upload validation, and Metadata Views to maintain a searchable index of your production assets. The combination keeps your local workflow fast while giving your team a centralized view of asset metadata.
Workflow Integration
A practical SVG metadata workflow for a design team:
- Export: Designer exports SVG from their tool (Figma, Inkscape, Illustrator)
- Validate: A CI step runs ExifTool or a Python script to check that
<title>and<desc>exist for accessibility - Optimize: SVGO strips editor metadata and reduces file size
- Index: Upload to a shared workspace where metadata is extracted and searchable
- Audit: Periodically review the metadata index to find files missing titles, descriptions, or license information
This pipeline catches accessibility gaps early, keeps production SVGs lean, and gives asset managers a searchable catalog without manual data entry.
Frequently Asked Questions
What metadata is stored in SVG files?
SVG files can contain descriptive elements (title and desc tags), a metadata block with Dublin Core RDF properties like creator, rights, and dates, root attributes like viewBox, width, and height, namespace declarations, and editor-specific attributes from tools like Inkscape (sodipodi and inkscape namespaces) and Adobe Illustrator (XMP metadata). Since SVG is XML-based, all of this is stored as readable text.
How do I extract the title from an SVG?
The quickest way is to open the SVG in a text editor and look for the <title> element near the top of the file. Programmatically, use xmllint with the XPath expression "//*[local-name()='title']/text()" or parse the file with Python's ElementTree and call root.find() with the SVG namespace. In JavaScript, DOMParser can parse the SVG string and querySelector("title") returns the element.
Can ExifTool read SVG metadata?
Yes. ExifTool supports SVG files for reading. Running "exiftool file.svg" returns fields including SVG Version, Image Width, Image Height, View Box, Title, Description, and any XMP or Dublin Core metadata embedded in the file. You can also use ExifTool for batch extraction across directories with the -csv and -r flags.
How do I remove metadata from SVG files?
SVGO is the most common tool for stripping SVG metadata. Running "npx svgo input.svg -o output.svg" removes editor namespaces, comments, metadata blocks, and unused declarations by default. Inkscape's "Save as Plain SVG" option removes Inkscape-specific attributes. ExifTool can also strip metadata with "exiftool -all= file.svg" while preserving graphic content.
What is the difference between SVG title, desc, and metadata elements?
The title element provides a short, human-readable name for the SVG or a specific element within it. Browsers display it as a tooltip and screen readers announce it. The desc element holds a longer text description for accessibility. The metadata element is a container for machine-readable structured data, typically Dublin Core properties in RDF/XML format. Title and desc are meant for humans, while metadata targets automated systems and search engines.
How do I extract viewBox dimensions from an SVG?
The viewBox is an attribute on the root svg element, not a child element. Extract it with xmlstarlet using the XPath "//*[local-name()='svg']/@viewBox", with Python using root.get("viewBox"), or with JavaScript using svg.getAttribute("viewBox"). The value is four space-separated numbers representing min-x, min-y, width, and height of the coordinate system.
Do Figma SVG exports contain metadata?
Figma SVG exports are relatively minimal compared to Inkscape or Illustrator. They typically include the root svg element with viewBox, width, and height attributes, but do not embed Dublin Core metadata, XMP blocks, or editor-specific namespaces. Layer names may appear as id attributes on groups. If you need metadata in Figma exports, you would add it manually after export.
Related Resources
Manage SVG Metadata Across Your Asset Library
Upload SVG files to a Fastio workspace, extract metadata into a searchable spreadsheet with Metadata Views, and keep your team's asset catalog organized. generous storage, no credit card required.