XML to Java Converter
Paste XML and get Java POJO classes with JAXB annotations — nested classes, List<T> for repeated elements, and inferred scalar types.
Last updated: May 28, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is XML to Java Converter?
This converter parses an XML document and generates Java POJO classes annotated for JAXB (Jakarta XML Binding). Attributes become @XmlAttribute fields, child elements become @XmlElement fields, and repeated sibling elements become List<T> fields. Nested XML structures produce nested Java classes.
How to Use XML to Java Converter
Paste XML into the input panel.
Set a root class name (optional — defaults to XML root tag).
Set a package name if needed.
Toggle JAXB annotations and List<T> vs array for repeated elements.
Copy the generated Java code.
Common Use Cases
- Generating Java models for XML REST or SOAP API responses.
- Scaffolding JAXB classes for XML configuration file parsing.
- Creating Java DTOs for an XML data feed.
- Producing model classes before writing Jakarta XML Binding code.
Example Input and Output
An XML order with nested customer and repeated items becomes Java POJO classes.
<order id="A1"><customer><name>Alice</name></customer><item><sku>BK1</sku><qty>2</qty></item></order>@XmlRootElement(name = "order")
@XmlAccessorType(XmlAccessType.FIELD)
public class Order {
@XmlAttribute(name = "id")
private String id;
@XmlElement(name = "customer")
private Customer customer;
}Tip
Add the jakarta.xml.bind:jakarta.xml.bind-api Maven dependency and an implementation like glassfish JAXB RI to use the generated classes.
Frequently Asked Questions
What is JAXB?
JAXB (Jakarta XML Binding, formerly Java Architecture for XML Binding) is a standard Java API for mapping XML to Java objects and back.
How are repeated elements handled?
Repeated sibling elements with the same tag name become List<T> fields when the List option is enabled.
Is the XML sent to a server?
No. All XML parsing and Java class generation happen in your browser.
Related Tools
XML to C# Converter
Generate C# classes from XML, including XmlRoot, XmlElement, XmlAttribute, lists for repeated elements, nullable properties, and optional namespace wrapping.
XML to Dart Converter
Generate Dart classes from XML, including nested classes, List<T> fields for repeated elements, optional final fields, nullable types, and fromJson/toJson methods.
XML to Go Converter
Generate Go structs from XML, including nested structs, slices for repeated elements, optional XML attribute preservation, scalar inference, and struct tags.
JSON to Java Converter
Generate Java POJO classes from a JSON example. Infers types, creates nested classes, handles arrays as List<T>, and optionally uses Lombok @Data or full getters/setters.
XML to JSON Converter
Parse and convert XML to clean JSON instantly — attributes, namespaces, and nested elements handled.
XML to TypeScript Converter
Generate TypeScript interfaces from XML. Preserves nested elements as typed interfaces, handles repeated elements as arrays, and supports optional attributes and scalar inference.

