Dart to XML Converter
Paste Dart classes or objects. Get clean XML back.
Input
Output
Paste your Dart code on the left and press Convert.
Or drop a file on this box, , or .
What this tool does
Flutter apps still end up talking XML: a SOAP endpoint at an insurer, an RSS feed, a payment provider that never moved to JSON. Shaping that payload by hand from a Dart model is tedious. Paste the model here, ideally with a constructed instance, and you get XML whose elements follow your fields. A class with final fields, a whole models.dart or a single Order(...) call are all valid starting points.
It understands normal Dart constructors. Named required parameters line up with the fields they assign, so values land in the right elements, and final makes no difference to the output. DateTime values print as ISO-8601, a Duration as an ISO-8601 period such as PT2H30M, and a String? holding null keeps an empty tag. A List<OrderItem> field turns into a wrapper with one <OrderItem> per entry, close to what you would build with the xml package's XmlBuilder.
The class layout carries over. The outer class names the root element, each field gets a child, nested classes are expanded in place and a Map<String, V> becomes a run of key/value entries. @JsonKey from json_annotation is a JSON concern, so the XML keeps the Dart field name. Plain classes from a Flutter app and freezed-style models both work; the result reads like XML you would have built with XmlBuilder, minus the builder calls.
How to use it
Paste the Dart, press Convert, copy the XML. One model class and an entire lib/models file go through the same three steps.
Paste your Dart (or try the sample)
Paste Dart into the left editor: a plain class, a data class with a named constructor, several classes at once, or a constructed instance. Load Sample fills in an Order built with named required parameters, two line items and an address.
import and part lines and annotations can stay. Code generation is not a prerequisite either; the converter works from the class you wrote, not the generated .g.dart file.
Hit Convert
Press the green Convert button. Your Dart is sent to the backend, which lines up constructor arguments with fields and writes out the document. Both editors are dimmed under a "Converting..." overlay until it finishes.
Copy the XML
The read-only panel on the right shows indented XML that opens with an XML declaration. Copy it into a SOAP request, an asset file under assets/, a platform config, or a flutter_test fixture.
When this actually comes in handy
Flutter apps talking to SOAP services
Your Flutter app has to call a legacy SOAP endpoint and the request body has to match a Dart model. Paste the model, take the XML, feed it to http.post or the xml package.
RSS and Atom feed generators
Building a podcast or news app that publishes RSS? Paste the episode model, get the XML shape you need, then wrap it with the feed envelope, no hand-counting <item> children.
Android/iOS native XML configs
Need to produce an Android-style preferences XML or an iOS plist-like structure from a Dart model used in platform channels? Paste the class and get a ready-to-tweak template.
Test fixtures for flutter_test
Turn a populated model into an XML fixture file for flutter_test, widget golden tests, or mock HTTP responses: a faster path than writing fixture strings by hand.
Common questions
Can I paste several classes at once?
Yes, paste the full models.dart. All top-level classes are picked up, nested classes appear inline at the point they are referenced, and fields a class gets from its superclass or a mixin are included. Classes with nothing in common end up side by side under one <Root> element.
Does it work with freezed or json_serializable data classes?
Yes. Freezed-style immutable classes and json_serializable-annotated models are treated as regular Dart classes: fields come through. @JsonKey(name: "x") only renames the JSON key, so it is ignored here and the element keeps the Dart field name; xml_serializable-style @XmlElement(name: 'x') and @XmlAttribute are honoured. You do not need to run build_runner or paste the generated .g.dart file.
How are DateTime, Duration, null, and num handled?
DateTime becomes an ISO-8601 timestamp like 2026-04-21T10:15:00.000Z, and a two and a half hour Duration is written as PT2H30M. A nullable field that is null gives you a self-closing element instead of disappearing. num, int and double are all written as ordinary decimal text.
What about List, Map, and nested classes?
A List<OrderItem> items field becomes an <items> element containing one <OrderItem> per entry; a Set works the same way, and lists of primitives use Item as the child name. A Map<String, V> becomes a list of entries, each with a key and a value inside. Nested classes are expanded where they appear, like nested builder.element() calls.
Is my code stored?
Your Dart is handed to the backend just long enough to build the XML, which then shows up on the right. It is not kept afterwards, and this page has no history or saved state. Flutter code tends to carry API keys and base URLs in constants, so swap those for placeholders before pasting.
What if the class uses dynamic or Object? fields?
Fields typed as dynamic or Object? are serialized as string text based on their assigned literal value, since the actual shape is only known at runtime. If you want stronger XML output, narrow the type (String, int, a concrete class) and the converter will pick up the structure automatically.
Other tools you may need
After converting a Dart model, these pages let you check the XML, generate Dart classes from an XML sample, or get the JSON version of the same object: