Report Tool or Give Us Suggestions

XML to Dart POJO Generator

Generate Dart data classes with fromJson/toJson maps from XML samples in the browser.

L ading . . .

Convert an XML document into Dart data classes with fromJson and toJson helpers ready to use in Flutter or pure Dart projects. Paste any XML payload, choose a root class name, and the tool parses the structure with fast-xml-parser and emits typed Dart classes for every nested element and attribute—entirely client-side.

What the tool generates

  • Immutable Dart classes with final fields and a named constructor where every field is required.
  • fromJson factory that maps each XML element or attribute back into the typed field using Map<String, dynamic> casts.
  • toJson method returning a Map<String, dynamic> with the original XML element and attribute names preserved.
  • Nested classes for child elements and List<T> typing inferred from repeated tags.

Why convert XML to Dart?

Many legacy SOAP services, RSS feeds, and configuration files still ship XML payloads while modern Flutter apps prefer typed Dart models. Generating data classes by hand for deeply nested XML is tedious and error-prone. This converter walks the parsed tree, infers a Dart type for every leaf, and writes ready-to-paste classes that round-trip through a Map<String, dynamic> so you can keep using jsonEncode/jsonDecode-style serialization downstream.

Type inference

  • true / falsebool
  • Integer values → int
  • Decimal numbers → double
  • String values → String
  • Child elements → nested Dart class named after the parent class and tag
  • Repeated tags → List<T> with item type from the first non-null entry

Identifier safety

Field names are converted to camelCase and Dart reserved words (such as class, new, final) are suffixed with Value so the output compiles cleanly. Attribute names (prefixed with @_ internally) are stripped to plain camelCase identifiers, and the special #text node becomes a text field on the parent class.

Known limitations

Heterogeneous arrays infer their item type from the first non-null element. XML namespaces are kept as part of the tag name. Mixed content (text and child elements in the same tag) produces a class with both a text field and typed children. CDATA blocks are returned as plain strings.

Frequently Asked Questions

Does the generated Dart code depend on extra packages?

No. The classes are plain Dart with hand-written fromJson and toJson, so no json_serializable, built_value, or code generation step is required.

How are XML attributes handled?

Attributes are mapped to regular fields on the parent class using their plain name. For example <book id="bk101"> becomes an id field on the Book class.

How are repeating tags mapped to lists?

When the parser sees the same tag more than once at the same level it produces an array. The tool emits List<T> using the inferred class or primitive type of the first element as the item type.

Is the XML uploaded anywhere?

No. Parsing and code generation run entirely in your browser. Your XML never leaves the page.

Can I change the root class name?

Yes. Use the Root class name input—it is converted to PascalCase before being applied to the top-level class and prefixed onto nested class names.

logo OnlineMiniTools

OnlineMiniTools.com is your ultimate destination for a wide range of web-based tools, all available for free.

Feel free to reach out with any suggestions or improvements for any tool at admin@onlineminitools.com. We value your feedback and are continuously striving to enhance the tool's functionality.

© 2026 OnlineMiniTools . All rights reserved.

Hosted on Hostinger

v1.10.0