TsWorks Tools
All tools (39)

XML to TypeScript

Generate TypeScript interfaces from an XML document.

Declare as

Attributes become keys prefixed with @.

Paste XML. Attributes and repeated elements are preserved.

XML to TypeScript

Paste an XML payload and get TypeScript interfaces for the shape a parser would hand you. Useful against SOAP responses, RSS feeds and the older half of most integrations.

What the generated types assume

That you will parse the XML with the same conventions this tool reads it by: attributes as @-prefixed fields, repeated elements as arrays, mixed content under #text. Those are the conventions XML to JSON uses and the ones most browser and Node XML libraries default to.

One element is not an array

This is sample-based, and the sample is one observation. If your document happens to contain a single <item>, the field is typed as one item rather than as a list, because nothing in the document says it could repeat. Paste a sample with at least two, or widen the type by hand - a schema is the only thing that can actually answer this, and XML documents rarely travel with one.

Repeated shapes are named once

Two hundred <book> elements produce oneBook interface, not two hundred anonymous inline types, and a field missing from some of them is marked optional.

Related tools