Paste Swift on the left and click "Convert" — we will turn it into XMLPaste Swift code

What this tool does

If you have ever had to hand-write XML that mirrors a Swift struct — for a plist, a SOAP client talking to a legacy ERP, or an XMLParser test fixture — you know how many curly braces you end up typing. Paste the Swift here and you get back well-formed XML in one pass. A single struct, a file with several structs and enums, or a populated let order = Order(...) instance — same result: a complete XML document with every property preserved.

It is not dumb string-replacement. The converter knows how Swift actually serialises — roughly the way a Codable-driven XMLEncoder would handle things. Decimal values come out as plain numeric text, Date becomes an ISO-8601 string, UUID becomes the standard 8-4-4-4-12 hex format, and Optional<T> with a nil value becomes an empty element rather than disappearing. Arrays follow a consistent container shape — each array becomes a wrapper element with one child per item, named after the element type.

Coding customisations are honoured too. A nested enum CodingKeys: String, CodingKey remaps property names in the output, so orderId can surface as OrderId in the XML without you touching the struct. Nested structs and enums are expanded inline. If you paste several types, each one lands in the output with its shape intact — the converter follows the same broad design goals as the Swift API Design Guidelines, so names and casing stay predictable.

How to use it

Three steps. Works the same whether you paste a five-line struct or a full model file.

1

Paste your Swift (or try the sample)

Drop your Swift into the left editor as-is. A struct, an enum with associated values, a populated let instance, or a file with multiple types — all fine. Click Load Sample if you want to see a realistic example first.

You do not need to strip import statements, remove @propertyWrappers, or clean up Swift syntax. Leave the code the way it looks in Xcode. Just paste.

2

Hit Convert

Click the green Convert button. The tool reads the Swift, preserves every type and property, and builds the XML in one pass. You will see a short loading indicator while it runs.

3

Copy the XML

The right panel fills with indented, well-formed XML that a standards-compliant XML parser (XMLParser, lxml, System.Xml, you name it) will accept. Copy it straight into your plist, SOAP body, or test fixture.

When this actually comes in handy

iOS / macOS plist generation

Take a Swift settings struct and get an Info.plist-style XML document you can drop straight into Xcode — no hand-typed <code>&lt;key&gt;&lt;/key&gt;</code> pairs, no whitespace bugs. Pairs well with Apple's <a href="https://developer.apple.com/documentation/foundation/propertylistserialization" target="_blank" rel="noopener">PropertyListSerialization</a> APIs on the decoding side.

SOAP clients on Apple platforms

A Swift request type needs to leave the app as SOAP. Paste the struct, drop the XML body into SoapUI or Postman, verify the contract without writing the envelope by hand.

Seeding test fixtures

Turn a populated <code>let order = Order(...)</code> from a unit test into an XML seed file for XCTest integration tests, mock servers, or backend systems that still speak XML.

Keeping docs in sync

Generate XML examples for a README, an internal wiki, or XSD-backed schema docs directly from your actual Swift models, so the documentation never drifts out of step with the code.

Common questions

Can I paste multiple structs at once?

Yes — paste a whole file. Each top-level struct or enum comes through with nested types expanded and default values filled in. Nothing is dropped silently.

Does it honour CodingKeys?

Yes. A nested enum CodingKeys: String, CodingKey remaps property names in the XML output — case orderId = "OrderId" will emit <OrderId> instead of <orderId>. Properties not listed in CodingKeys fall back to their Swift name. This matches how Codable works in practice.

How does it handle Decimal, Date, and Optional?

Decimal comes out as plain numeric text. Date becomes an ISO-8601 string. UUID becomes a standard 8-4-4-4-12 hex string. Optional<T> with a nil value becomes an empty element rather than disappearing — so the shape stays consistent for consumers who validate against an XSD.

What about enums with associated values and arrays?

Enums with associated values are emitted with a discriminator attribute naming the case, plus child elements for the associated values — enough to round-trip them. Arrays become a container element with one child per item, named after the element type. Dictionary<K,V> becomes a container of <Entry><Key/><Value/></Entry>.

Is my code stored?

Your code is sent to the backend for conversion and is not persisted — we do not log the payload. As always with online tools, if the code is genuinely sensitive, look it over before pasting.

What if the Swift has property wrappers, protocols, or computed properties?

Property wrappers are unwrapped to the underlying value in the output. Protocols define shape, not content, so they do not produce XML directly — but conforming types do. Computed properties are skipped since they are derived, not state. If the code has syntax errors, fix the obvious ones first — the parser is forgiving but not psychic.

Other tools you may need

Swift to XML is one piece of the puzzle. These tools pair well with it: