Free XML to Dart Class Generator Online
Generate Dart classes from XML instantly in your browser.
XML Input
Dart Output
What Is XML to Dart?
When a Flutter or Dart app needs to consume XML — from a SOAP API, RSS feed, or config file — you have to write class definitions with all those final fields and a constructor by hand. Dart's xml package makes parsing straightforward, but the model layer is still tedious. This tool scaffolds the Dart class with final fields and optional nullable types so you can wire up Dart or Flutter logic immediately. The W3C XML specification defines the format — and everything runs in your browser via the DOMParser API. Nothing leaves your machine.
How to Use This Tool
Paste or Upload XML
Paste XML or upload a file. Set class name, package, Data Class, and Nullable Types in the config.
Review Dart Output
The right panel shows generated classes. Use the xml package to parse and populate.
Copy or Download
Use Copy or Download. For JSON to Dart, use JSON to Dart. For XML formatting, use XML Formatter.
When XML to Dart Helps
When building Flutter apps that consume XML APIs or config, generate typed classes here. Use the xml package to parse. For Dart server apps, the same classes work with any XML source.
Frequently Asked Questions
Which Dart package should I use for XML parsing?
The xml package on pub.dev is the standard choice. Add xml: ^6.0.0 to your pubspec.yaml, then use XmlDocument.parse(xmlString) to parse and walk the tree. It works in both Flutter and Dart CLI apps.
How do I use the generated class with the xml package?
Parse the document with XmlDocument.parse(), then use .findElements('tagName').first.innerText to extract field values and assign them to your class. The generated class gives you the exact property names to target.
Can I use this with Flutter's http package?
Yes. Make an HTTP request with Flutter, get the response body string, parse it with XmlDocument.parse(response.body), and populate your generated Dart class. The class works as a plain Dart object in any widget or provider.
Is my XML data sent to a server?
No. All processing runs locally in your browser using the DOMParser API. Nothing is uploaded or stored anywhere.
Does it handle nested XML elements?
Yes. The tool recursively maps nested XML elements to nested Dart classes. So a structure like <order><item>...</item></order> produces an Order class with an Item field. Deep nesting works too — each level becomes its own class.
Can I use the generated class directly in a Flutter app?
Yes. The generated class is plain Dart — no annotations or code generation needed. Add the xml package to your pubspec.yaml, parse your response with XmlDocument.parse(), then manually assign fields from the tree. It works in any Flutter widget, provider, or BLoC without any extra setup.
XML to Dart Examples
Here is an example of generating Dart classes from XML.
Example: Subscriber record
XML input:
Generated Dart output:
Related Tools
For Dart XML parsing, see the xml package and Dart guides. For XML, see the W3C XML spec and W3C XML. For parsing in the browser, see MDN DOMParser. For JSON, see json.org.