skillfed

xacro

xacro is a macro language for XML

xacro v2.1.1 201.8K downloads/30d#9,664 on PyPI124
License unclear Copyright Robert Haschke, Bielefeld University Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) Active released

What it is and what it does

Xacro is a macro preprocessor for XML that allows you to define reusable templates and macros, then expand them into full XML documents. It reduces repetition and improves readability by letting you write shorter, more maintainable XML source files that are transformed into the final XML output. The package depends only on pyyaml and requires Python 3.8 or later.

It is commonly used in robotics and configuration contexts where XML files would otherwise contain significant duplication. You write xacro source files with macro definitions and calls, then process them through xacro to generate the expanded XML output.

Use it for:

  • Generate robot configuration files in ROS by defining reusable component macros instead of repeating XML blocks
  • Preprocess XML configuration files to reduce boilerplate and improve maintainability across multiple similar configs
  • Template XML documents where sections repeat with minor parameter variations
  • Build XML files programmatically using macro definitions rather than string concatenation

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Xacro is an XML macro language that lets you write shorter, more readable XML files by defining macros that expand into larger XML expressions.

Yes, if you work with XML files that contain repetition or need templating. The package is actively maintained, has low install friction, and no known vulnerabilities. The unclear license treatment is a minor concern—review the BSD 3-Clause text in the repository to confirm it aligns with your project before committing to it.

Install

xacro on PyPI

pip

pip install xacro

uv

uv add xacro

poetry

poetry add xacro

Installing xacro

Before you install

Low install friction with a single runtime dependency (pyyaml). The package is actively maintained with a recent commit on 2026-04-07 and has been in active development since its first release on 2018-09-18.

License in practice

License treatment is unclear; the package uses a BSD 3-Clause-style license text but no SPDX identifier is recorded. You should review the full license text in the repository before use to confirm it meets your project's requirements.

Quickstart

pip install xacro

import xacro
xacro.process_file('input.xacro', output='output.xml')

Requires Python 3.8 or later; input file must be a valid xacro XML document with macro definitions or includes.

Verify before relying

  • Whether the BSD 3-Clause license text is the canonical license or if an SPDX identifier should be assigned
  • Whether xacro is primarily used within the ROS ecosystem or has broader XML-processing applications

Package facts

License Copyright Robert Haschke, Bielefeld University Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.… (full text in the JSON record) (unclear)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pyyaml
Maintenance actively maintained — 351 days since the last release
Last repo commit
First released
Downloads 201,771/month — #9,664 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: xacro-2.1.1-py3-none-any.whl

Tags

xml macro languagexml templatingxml code generationreduce xml boilerplatexml preprocessingmacro expansion xmlxml reusable components
xml-preprocessingros-ecosystem

More Markup packages