Free XML to Rust Struct Generator Online
Generate Rust structs with serde from XML instantly in your browser.
XML Input
Rust Output
What Is XML to Rust?
When a Rust app needs to consume XML — from REST APIs, config files, or SOAP services — you have to write struct definitions and wire up serde attributes by hand, which is tedious. quick-xml supports serde and is the go-to crate for fast XML parsing in Rust, while roxmltree offers a simple DOM-like interface. This tool scaffolds the struct skeleton with Cargo.toml-ready serde derives. The W3C XML specification defines the format — and everything runs in your browser via the DOMParser API. Nothing leaves your machine.
How to Use This Tool
Paste or Upload XML
Paste XML or upload a file. Set struct name and package (module) in the config.
Review Rust Output
The right panel shows generated structs. Add quick-xml or serde with xml support to Cargo.toml and parse.
Copy or Download
Use Copy or Download. For JSON to Rust, use JSON to Rust. For XML formatting, use XML Formatter.
When XML to Rust Helps
When building Rust apps that consume SOAP, feeds, or XML config, generate structs here. Add quick-xml or roxmltree to Cargo.toml and parse.
Frequently Asked Questions
quick-xml vs roxmltree — which should I use?
quick-xml is a high-performance streaming parser that integrates directly with serde — ideal for large feeds and production use. roxmltree is a simpler read-only DOM tree, great for small documents. If you need #[derive(Deserialize)] to just work, quick-xml with serde is the standard choice.
How do I add quick-xml to my project?
Add quick-xml = { version = "0.36", features = ["serialize"] } and serde = { version = "1", features = ["derive"] } to your Cargo.toml. Then use quick_xml::de::from_str(&xml) to deserialize directly into your generated struct.
Why are there #[serde(rename)] attributes on some fields?
XML element names are often camelCase (e.g. planName) but Rust convention uses snake_case (plan_name). The #[serde(rename)] attribute bridges the two so serde can map the XML field to the correct Rust field name during deserialization.
Is my XML data sent to a server?
No. All processing runs locally in your browser using the DOMParser API. Nothing is uploaded or stored anywhere.
XML to Rust Examples
Here is an example of generating Rust structs from XML.
Example: Subscriber record
XML input:
Generated Rust output:
Related Tools
For Rust XML parsing, see quick-xml and roxmltree. For XML, see the W3C XML spec and W3C XML. For parsing in the browser, see MDN DOMParser. For JSON, see json.org.