F# to XML Converter

Paste F# records or values. Get clean XML back.

Input

Output

Paste your F# code on the left and press Convert.

Or drop a file on this box, , or .

What this tool does

F# record types describe a config section or a SOAP message very neatly, and then you still have to write the XML for it by hand. Paste the records here, along with a let binding that fills one in, and the page answers with well-formed XML laid out like those records. One record, a whole module, or a value built from nested records all work.

F# types are mapped the way you would expect from .NET. A string option holding Some "Leave at the door" is written as ordinary text, while the sample's Notes = None still produces a <Notes> element, just an empty one. The m on 249.99m disappears, units of measure are stripped from numbers, and the Items: OrderItem list field is written as an <Items> block containing an <OrderItem> for each record, much like System.Xml.Serialization nests collections.

A discriminated union value is written as an element named after the case, with the case's fields inside it. Nested records become nested elements, a tuple field gives <Item1>, <Item2> children, and a Map turns into a series of key/value entries. If your records carry [<XmlElement>] or [<XmlAttribute>] from the .NET serialization attributes, they rename the element or move the value onto an attribute.

How to use it

Three steps. Works the same way whether you paste a one-line record or a whole module.

1

Paste your F# (or try the sample)

Paste F# into the left editor: a record type, a filled-in let binding, a module of several records, or a discriminated union. Load Sample gives you an Order record with a decimal total, an option field set to None and an OrderItem list.

open declarations and comments do no harm, and indentation-based layout is read as written, so paste straight from Rider or VS Code. The FSharp.Core docs list the collection types that get special handling.

2

Hit Convert

Press the green Convert button. Behind it, the backend reads your record definitions, follows the populated value through them and answers with the XML. The two editors sit under a "Converting..." overlay meanwhile.

3

Copy the XML

A two-space indented document with an XML declaration appears in the right-hand panel. Copy it into an app.config, a WCF test, an XmlSerializer round-trip check or a page of your docs.

When this actually comes in handy

.NET XML config files

Model an app.config or web.config section as an F# record, paste it, and you have the matching XML block to fill in rather than typing every tag yourself.

WCF and SOAP fixtures

You have an F# record that mirrors a WCF data contract. Paste it, get the SOAP-shaped body, drop it into SoapUI or Postman.

Fable interop with legacy XML endpoints

Using Fable to talk to an older XML API? Paste the shared F# record and get the XML body your backend expects, with option fields handled correctly.

Test data for XmlSerializer

Generate XML seed data that round-trips through XmlSerializer<T> without surprises: helpful for integration tests, mock servers, and regression suites.

Common questions

Can I paste multiple records at once?

Yes. Paste a whole module. Each record type comes through with nested records expanded and any and-chained type definitions handled. Discriminated union cases keep the case name as the element tag.

How does it handle option, None, and defaults?

An option<string> with Some "x" becomes a normal element containing the text. None becomes an empty element so the shape stays stable: you will not lose fields between records that are populated and records that are not. voption behaves the same way.

What about decimal, DateTime, Guid, and the tricky types?

Decimals (249.99m) drop the suffix and become plain numeric text. DateTime, DateTimeOffset, and TimeSpan become ISO-8601 strings. Guid stays in the canonical 8-4-4-4-12 hex format. byte[] becomes base64 text: matching XmlSerializer behaviour.

Do discriminated unions work?

Yes. A DU like type Status = Active | Suspended of reason: string emits <Active/> for the nullary case and <Suspended><reason>...</reason></Suspended> for the payload case. The case name lands as the element tag, which is usually what you want for XML that matches a schema.

Is my code stored?

The backend receives your F# for this one conversion, sends the XML back and keeps nothing. The page has no save feature either. Records often sit next to connection strings in the same module, so paste the type definitions and the sample value, not the whole file, if that applies to you.

What if the F# uses computation expressions or active patterns?

Those do not produce XML fields: they are control-flow constructs, not data. We look at the record type definitions and the populated instance, so an async { ... } or a banana-clip pattern match is ignored. Fix any obvious syntax errors first so the parser has something clean to chew on.

Other tools you may need

After turning F# records into XML, these pages help with validation, with going the other way, and with getting a JSON version of the same value: