quick-xml
A high-performance, near-zero-copy XML pull parser and writer for Rust
Repository Health
Technical Analysis
quick-xml is a Rust library for reading and writing XML that prioritizes raw throughput and low memory overhead. Its reader is a pull-based event API — callers drive a loop pulling Start/End/Text/Eof events rather than being pushed a full DOM tree — and it borrows from the input buffer using Cow wherever possible instead of copying, while letting callers reuse buffers across reads to keep allocations low.
Beyond the low-level event reader/writer, quick-xml ships an optional serialize feature that integrates with Serde’s Serialize/Deserialize traits, letting Rust structs map directly to XML elements and attributes (including the special $text/$value conventions for tag bodies). Benchmarks in the project’s own README show it roughly 10-50x faster than the older xml-rs crate, which has made it the default choice for XML-heavy Rust codebases handling large or high-throughput documents.
What You Get
- A pull-based Reader emitting borrowed (Cow-backed) Start/End/Text/Eof events with minimal copying
- A Writer API for constructing XML documents element-by-element, including attribute manipulation
- Optional Serde Serialize/Deserialize support for mapping Rust structs directly to XML via the
serializefeature - An
encodingfeature for handling non-UTF-8 XML documents and namespace resolution - Reusable read buffers so long-running parsers can keep allocation overhead low
Common Use Cases
- Parsing large or high-throughput XML documents (logs, feeds, exports) where allocation overhead matters
- Deserializing/serializing typed configuration or data-interchange formats expressed as XML via Serde
- Building XML-based file format readers/writers (e.g. SVG, RSS, Office Open XML-style formats)
- Streaming XML processing where holding a full DOM in memory is undesirable
Under The Hood
Architecture: quick-xml centers on a pull-parser Reader that callers drive in a loop, calling read_event() or read_event_into() and matching on an Event enum (Start, End, Text, Eof, and others) rather than the library pushing a full parsed tree; a companion Writer mirrors this by accepting Event values and serializing them back to bytes via a Cursor-backed sink. Because the reader hands back borrowed Cow-based views into the input rather than copying by default, the API pushes callers to manage a scratch buffer themselves (buf.clear() between iterations), trading some ergonomic overhead for lower allocation pressure. The optional serde module layers typed (de)serialization on top of this same event stream, translating XML elements/attributes to Rust struct fields using @-prefixed and $text/$value naming conventions inspired by serde-xml-rs.
Tech Stack: The crate is pure Rust (100% of tracked bytes) with an MSRV of 1.79.0, gated features for encoding (non-UTF-8 input) and serialize (Serde integration) so consumers opt into only the functionality they need, and a documented benchmark suite comparing itself against xml-rs and serde-xml-rs to substantiate its performance claims.
Code Quality: The repository includes 25 dedicated test files under tests/, a fuzz/ directory for fuzz-testing the parser against malformed input, a benches/ directory with criterion-style benchmarks, and a test-gen/ helper for generating additional test fixtures — a notably mature testing setup for a parsing library where malformed-input robustness matters. CI runs via GitHub Actions (badge in README) and the project publishes coverage via codecov. With 135 contributors and steady commit cadence (34 tagged releases, ~17 commits/month), maintenance is active and broad-based rather than single-maintainer.
API Design: The event-driven Reader/Writer API keeps the core surface small — a handful of methods (read_event, write_event, config_mut) cover most usage — but requires callers to understand pull-parsing and buffer-reuse patterns upfront, which raises the initial learning curve compared to a simple parse_str() -> Document API. The optional serde layer substantially lowers this barrier for typed use cases, letting users skip the event loop entirely and just derive Serialize/Deserialize on their structs.
Used by 5 apps in this directory
Bramble
Password Manager · Security · Authentication
Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.
fabro
Developer Tools · Devops
Define AI agent workflows as code graphs, route tasks across any LLM, and intervene only where it matters.
Fluree DB
Databases
A temporal, verifiable graph database with git-like branching, integrated vector/text/geo search, and RDF/SPARQL/JSON-LD/openCypher support — benchmarked at 10.4x faster than the next database on the full Wikidata dump.
Jan
AI Assistants
Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.