One snapshot is a polite fiction
XML carries optional nodes, namespaces, repeated siblings, and attributes your sample might omit. This page reads whatever you paste, walks element children, and prints TypeScript-style shapes. Missing branches stay missing.
We treat the output as a starting point for code review, not as a contract.
Tags become properties, not promises
The built-in DOMParser builds a tree, each tag name turns into a PascalCase interface title, and child groups become nested interfaces or arrays when siblings repeat. Literal text nodes feed simple string, number, or boolean guesses. Attribute names arrive as optional camelCase fields.
Mixed content, comments, and processing instructions fall outside what the walk inspects. If your feed relies on any of those, note the gap before you merge the file into a shared package.
Micro example: line item priced at 24.99
Fragment
<Line sku="W-12"><Qty>3</Qty><Price>24.99</Price></Line>
Shape you should expect
export interface Line {sku?: string;qty?: Qty;price?: Price;}Nested Qty and Price blocks spawn their own interfaces because the generator mirrors structure, not business rules.
Wrong clipboard, same conference call
- Pasting pretty-printed HTML instead of XML triggers parser errors. Run XML Validator when you are unsure which dialect landed in the buffer.
- Assuming arrays because you saw two siblings once leads to brittle types. Duplicate tags in one sample become
Foo[]here, yet production might send zero or one row during quiet hours. - Renaming fields in TypeScript without updating serializers breaks runtime mapping. Generate first, rename second, grep third.
Where teams plug this in
Front-end crews sketch adapters while SOAP endpoints still answer in angle brackets. Backend engineers compare generated shapes against OpenAPI models before they wrap legacy services. Educators show how tree XML differs from JSON you get through our XML to JSON page when students ask why arrays feel different across formats.
JSON, Schema, or TypeScript: pick the artifact you need
| Goal | Better starting point |
|---|---|
| Runtime objects in JavaScript | XML to JSON for data without static typing noise. |
| Validation vocabulary for APIs | XML to JSON Schema when you need keywords, not TS syntax. |
| Editor hints inside a TS codebase | Stay on this page, export interfaces, tighten optionality by hand. |
Terms worth aligning with reviewers
- Optional everywhere
- Attributes and child nodes default to optional fields because absence is legal XML until your XSD or integration test proves otherwise.
- Unknown namespaces
- Prefixes differ between environments. Normalize externally, paste the cleaned tree, then regenerate so names stay stable.
When you need to reshape the tree before typing, open our XML Editor, carve the subtree, then return here with a smaller paste.
