How are XML attributes represented in the interface?
Attributes are emitted as string-literal keys with the prefix "@_" — for example "@_id": string. This matches the default convention of fast-xml-parser (attributeNamePrefix: "@_"). Because the @ character is not a valid bare identifier in TypeScript, the key must be quoted, which also visually separates attributes from element children when reading the interface.
What about namespaces — how are they shown?
fast-xml-parser preserves the prefix in the key by default (e.g. "ex:book"). The basic generator strips the prefix; if you need it, set removeNSPrefix: false in the parser options and rewrite the matching property keys with their prefix as a string literal: "ex:book": Book.
Is this compatible with fast-xml-parser?
Yes. The shape mirrors fast-xml-parser default options: attribute keys prefixed with @_, repeated elements as arrays, and text content under #text when an element has both text and attributes. Cast the parsed result with const data = parser.parse(xml) as Root.
Or xml2js — does the same interface work?
No. xml2js wraps every value in an array by default and puts attributes under a $ property: { book: [{ $: { id: "bk101" }, title: ["..."] }] }. Use a different generator preset, or post-process the xml2js output to flatten arrays before casting to a fast-xml-parser-shaped interface.
How are repeated elements like <tag> in <tags> represented?
Repeated child elements become a Tag[] array property. fast-xml-parser auto-detects arrays for repeated keys; for single-element-or-array ambiguity, configure isArray: (name) => ["tag"].includes(name) so the array is always present.
Can elements with attributes and text content be modeled?
Yes. <price currency="USD">39.99</price> generates a Price interface with two properties — "@_currency": string for the attribute and "#text": number for the text body. fast-xml-parser populates both when textNodeName is left at its default.
Is the XML I paste sent to your servers?
No. XML is parsed by the browser DOMParser and the TypeScript code is generated entirely in JavaScript on your machine. Open DevTools → Network and you will see no requests when you click Convert. Safe for SOAP responses and configuration files containing API keys or credentials.
How do I parse XML and cast to the generated interface?
With fast-xml-parser: import { XMLParser } from "fast-xml-parser"; const parser = new XMLParser({ ignoreAttributes: false }); const data = parser.parse(xml) as Root; — TypeScript now type-checks every access into the parsed object. The ignoreAttributes: false flag is required for attributes to appear as @_-prefixed keys.