Java to XML Converter
Paste Java classes or POJOs. Get clean XML back.
What this tool does
Hand-building the XML a Java class would marshal to is busywork that shows up everywhere: a SOAP client test, an old Spring applicationContext.xml, a bank integration that still speaks ISO-style XML, a JUnit fixture. Paste the class here, with or without a populated instance, and you get a well-formed XML document back. Several DTOs in one file, Lombok annotations and deep nesting are all fine.
The mapping follows Jakarta XML Binding (JAXB) habits. BigDecimal is printed in plain notation rather than 1E+2, LocalDate, LocalDateTime and Instant come out as ISO-8601 (the Instant one ending in Z), and a java.util.UUID stays in its toString() form. A List<OrderItem> field becomes a wrapper element with an <OrderItem> child for each entry, and a null Integer keeps its element with nothing inside.
Annotations are honoured exactly the way Eclipse JAXB RI treats them. @XmlRootElement(name="...") renames the root, @XmlElement(name="...") renames a child, @XmlAttribute emits the field as an attribute on the parent, @XmlTransient drops it entirely, and @XmlElementWrapper adds the outer container around a collection. Lombok @Data works too: the generated getters and setters are treated as bean properties. If you prefer the Jackson XML module, its @JacksonXmlProperty and @JacksonXmlElementWrapper are honoured as well. Nested classes, inherited fields, and multiple top-level classes all come through cleanly.
How to use it
Paste, press Convert, copy. A single POJO and a source file with a dozen DTOs follow the same route.
Paste your Java (or try the sample)
Paste the Java into the left editor. A plain POJO, a Lombok @Data class, a JAXB-annotated DTO or a file holding several classes all work. Load Sample drops in an annotated Order whose orderId is an @XmlAttribute, so you can see attributes and elements side by side.
The package line, imports and Javadoc can stay. Annotations matter here, so leave them on the fields: they are what decides element names and attributes.
Hit Convert
Press the green Convert button. The backend takes the source, looks at each field together with its JAXB or Jackson annotations and returns the marshalled form. While it works, a "Converting..." overlay covers the two panes.
Copy the XML
You get indented XML with an <?xml version="1.0"?> declaration on the right, readable by any XML parser. Select it from the read-only panel and paste it into a SOAP envelope, a Spring config, a src/test/resources file or the example section of an XSD.
When this actually comes in handy
Building SOAP fixtures
You have a JAX-WS or Apache CXF request DTO and need an XML body for SoapUI or Postman. Paste the class, get the envelope-ready XML, move on with your day.
Spring Boot XML configs
A Spring @ConfigurationProperties class with 30 fields becomes an XML skeleton listing every property with a default, which beats typing out applicationContext.xml entries one by one.
Keeping docs and code aligned
Generate XML examples for a README, an internal wiki, or XSD-backed schema docs straight from your actual entity classes, so the examples never drift from the code.
Seeding legacy integration tests
Turn your JUnit object-mothers into XML seed files for mock servers, IBM MQ fixtures, or legacy enterprise systems that still speak XML.
Common questions
Can I paste multiple classes at once?
Yes, a full .java file or several classes pasted together is fine. Classes that the root references are nested in place, superclass fields are added to the subclass element, and classes nothing references are still emitted, collected under a <Root> wrapper so the result stays one document.
Does it respect JAXB annotations like @XmlRootElement, @XmlElement, @XmlAttribute, and @XmlTransient?
Yes. @XmlRootElement(name="x") renames the root, @XmlElement(name="x") renames a child, @XmlAttribute(name="x") emits the field as an attribute on the parent, @XmlTransient drops it, and @XmlElementWrapper adds the outer container around a collection. This matches the behaviour spelled out in the JAXB tutorial.
What about Lombok and Jackson XML?
Lombok @Data, @Getter, and @Setter are treated as if the accessors were written by hand. Jackson XML annotations (@JacksonXmlProperty, @JacksonXmlRootElement, @JacksonXmlElementWrapper, @JacksonXmlText) are honoured too, so classes built for the Jackson dataformats-text XmlMapper come through correctly.
How does it handle BigDecimal, LocalDate, UUID, and null fields?
BigDecimal is written in full, never in exponent form. LocalDate, LocalDateTime and ZonedDateTime come out as ISO-8601 text, and an Instant gets the trailing Z. UUID appears exactly as uuid.toString() prints it. Optional.empty() and a null Long or Integer keep an empty element, so a batch of orders all share one shape for XSD validation.
Is my code stored?
Your source makes one trip to the backend, where the XML is generated, and the reply lands in the right-hand pane. No copy is saved on either side. For proprietary code, cut it down to the DTOs you need converted. Service classes and business logic contribute nothing to the XML anyway.
What if the class has something unusual: Streams, CompletableFuture, or a transient field?
transient fields and anything marked @XmlTransient or @JsonIgnore are left out. Fields of types with no XML meaning, such as a Stream, a CompletableFuture or a lambda, appear as empty elements and the other fields still convert. The input is read as source, not compiled, so if the output looks wrong, check that the class compiles with javac first.
Other tools you may need
With the Java model in XML form, these are good next steps for validating it, generating classes from XML, or comparing it with the JSON version: