InTab

XML to Code

Generate C# (XmlSerializer), Java (JAXB), Go and TypeScript classes that read your XML.

Converters: Turn one format into another. It runs in your browser, so nothing you enter is uploaded.

What it does

XML to Code generates classes that read your XML: C# for XmlSerializer, Java with JAXB annotations, Go structs with xml tags, and TypeScript interfaces. Paste a sample document and you get typed classes with the right attributes, elements and lists, plus a usage snippet.

How to use it

  1. Paste XML, or click Load sample.
  2. Choose the language.
  3. Optionally set the namespace (C#), package (Java, Go) or module (TypeScript).
  4. Copy or download the code. It regenerates as you type.

Example

<order id="1001">
  <customer>Ada</customer>
  <item sku="X1" qty="2" />
  <item sku="Y9" qty="1" />
</order>

Part of the C# output:

[XmlRoot("order")]
public class Order
{
    [XmlAttribute("id")]
    public int Id { get; set; }

    [XmlElement("customer")]
    public string Customer { get; set; } = string.Empty;

    [XmlElement("item")]
    public List<Item> Items { get; set; } = new();
}

How types are inferred

  • Repeated elements become lists, with a plural property name (item becomes Items).
  • Missing elements in some records become optional.
  • Numbers, booleans and dates are detected from the values: whole numbers become int (or long when large), decimals become decimal, and 2026-10-01 becomes a date.
  • XML namespaces are carried into the attributes.

Good to know

  • The more complete your sample, the better the classes: include an example of every optional element.
  • For SOAP responses, paste the inner payload rather than the whole envelope.

FAQ

Why does Java use Integer rather than int? Wrapper types can be null, which matches elements that may be missing.

Can I convert the XML to JSON instead? Yes, with the XML to JSON converter.

More Converters tools