Data to Class

XML to Java Class Generator

Turn an XML sample into Java classes, including nested elements and attributes.

Java Output
Output will appear here

Generate Java classes from an XML sample

Paste an XML document and get Java POJO classes generated from its structure — child elements become fields, repeated sibling tags become List<T> fields, and attributes are captured as fields too. Under the hood, this parses your XML with the browser's native parser, converts it to an equivalent structured object, and runs it through the same class generator as our JSON to Java tool.

How XML structure maps to Java

  • Child elements become private fields, typed and named the same way as the JSON-to-Java generator.
  • Repeated sibling tags (like multiple <item> elements) become a List<T> field.
  • Attributes are captured as separate fields, prefixed the same way they are in our XML to JSON converter (an @ prefix internally, mapped to a plain field name in the generated Java).

Typical use cases

  • Legacy SOAP/XML integrations: Scaffold Java model classes for an XML response from an older enterprise API.
  • Config or feed parsing: Generate classes for deserializing an XML config file or RSS/Atom feed with a library like JAXB.

Frequently Asked Questions

Not currently — the generated classes are plain POJOs describing the structure. Add @XmlElement/@XmlAttribute annotations by hand if you're using JAXB, based on which generated fields came from elements versus attributes.
Each attribute becomes its own field, generated the same way a JSON key would be — following the same attribute-prefixing convention used in our XML to JSON converter before being converted into a clean Java field name.
Yes, nesting of any depth is supported — each nested element becomes its own generated Java class, referenced from its parent.
No, parsing and class generation both happen entirely in your browser.