XML to C# Converter
Paste XML and generate C# classes suitable for XmlSerializer-style models, including attributes, elements, repeated lists, and nested classes.
Last updated: May 28, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is XML to C# Converter?
C# applications often deserialize XML into strongly typed classes with System.Xml.Serialization attributes. Writing those classes manually means inspecting the XML tree, deciding which values are attributes or elements, creating child classes, and representing repeated elements as lists.
This converter parses an XML sample and creates a starting set of C# classes. The root element receives an XmlRoot attribute, XML attributes become XmlAttribute properties, child elements become XmlElement properties, repeated child elements become List<T>, and simple text nodes get inferred scalar types when possible.
How to Use XML to C# Converter
Paste XML into the input panel.
Optionally set a root class name or namespace.
Toggle nullable properties and XML attribute support.
Copy or download the generated C# code.
Review inferred types and adjust names or serialization attributes for your project.
Common Use Cases
- Creating XmlSerializer models from a vendor XML sample.
- Bootstrapping C# POCO classes for XML API responses.
- Documenting an XML feed structure with typed classes.
- Converting repeated XML elements into List<T> properties.
- Generating starter code before adding validation or custom converters.
Example Input and Output
Repeated item elements become a List<Item> property and attributes become XmlAttribute properties.
<order id="A100"><item sku="BK-1"><quantity>2</quantity></item></order>[XmlRoot("order")]
public class Order
{
[XmlAttribute("id")]
public string? Id { get; set; }
[XmlElement("item")]
public List<Item>? Item { get; set; }
}Privacy
All XML parsing and class generation happens locally in your browser.
Production review
Generated classes are starter models. Review type inference, optional values, namespaces, collections, and custom XML names before using them in production.

