Go to XML Converter
Paste Go structs. Get clean XML back.
Input
Output
Paste your Go code on the left and press Convert.
Or drop a file on this box, , or .
What this tool does
You can always run xml.Marshal yourself, but that means a scratch main.go, a build, and a print statement, just to see what a Go struct turns into. When you are lining up a SOAP body, an RSS feed or a vendor's webhook format, it is quicker to paste the types here and read the XML straight away. A lone struct, a file with several types, or a composite literal lifted from Go by Example all produce a full document.
It mirrors what the encoding/xml package would actually produce. A tag like xml:"OrderId,attr" turns the field into an attribute on the parent; xml:"-" drops it; xml:",omitempty" leaves the element out when the value is the zero value; xml:"Items>OrderItem" wraps the slice in an <Items> container with one <OrderItem> per element; xml:",chardata" puts the value as text content. XMLName xml.Name renames the element itself. Pointer fields with nil values are emitted as empty elements only when ,omitempty is absent: exactly the way the standard library behaves.
Values print the way Go itself would print them. A float64 such as 249.99 stays in plain notation, a time.Time value is written in RFC 3339 form, and bool is a lowercase true or false. Unexported (lowercase) fields are skipped, as encoding/xml skips them. A slice without a > path in its tag repeats the field's element side by side, with no wrapper. Maps are something the standard library rejects outright, so here each key simply becomes an element holding its value. Effective Go describes the struct style the converter expects.
How to use it
Three short steps: paste the types, run Convert, take the XML. One struct or a whole models.go follows the same route.
Paste your Go (or try the sample)
Paste Go into the left editor: a bare struct type, a full file with its package and imports, or a composite literal such as order := Order{...}. Load Sample loads an Order whose tags use ,attr, Items>OrderItem, - and ,omitempty, so each tag form shows up in one result.
You do not need to strip the package line, remove imports, or tidy the file. Paste it the way it comes out of gofmt. Struct tags with backticks are expected.
Hit Convert
Press the green Convert button. The backend gets the source, interprets the struct tags one field at a time and builds the XML from them. A "Converting..." overlay hides the editors while that request runs.
Copy the XML
The XML appears on the right, opening with an XML declaration and indented two spaces per level, so any XML parser will take it. In the sample you will see OrderId as an attribute, the items wrapped in <Items>, and no InternalNote or empty Coupon. Select the read-only output and copy it where you need it.
When this actually comes in handy
Building SOAP client fixtures
You are talking to a legacy enterprise SOAP API from a Go service. Paste the request struct, get the XML body ready for SoapUI, Postman, or the test suite.
RSS and Atom feeds
A feed struct with Channel, Item, and enclosure fields turns into a working RSS or Atom template: handy for sanity-checking tag layout before wiring up the handler.
Vendor config files
Some SaaS tools still consume XML config (think sitemaps, logging pipelines, legacy ops consoles). Paste the Go config struct, drop the XML straight in.
Keeping docs honest
Generate XML examples for a README or API reference from the actual Go types, so the examples never drift out of sync with the code shipping in main.
Common questions
Can I paste multiple structs at once?
Yes. Paste the whole file. The root is detected from the composite literal (e.g. order := Order{...}) when present, or the first struct that references the others. Nested and sibling structs come through as nested elements or separate fragments, so nothing is dropped silently.
Does it honour struct tags like xml:"x,attr", xml:"-", and xml:",omitempty"?
Yes, and all of the common variants. xml:"name" renames the element, xml:"name,attr" emits it as an attribute on the parent, xml:"-" drops the field entirely, xml:",omitempty" skips zero-valued fields, xml:"a>b" wraps the slice in an <a> container with one <b> per element, xml:",chardata" puts the value as element text, and xml:",innerxml" is passed through as raw XML. This matches the behaviour documented in the encoding/xml Marshal reference.
What about the special XMLName field?
A field of type xml.Name named XMLName renames the root element. XMLName xml.Name `xml:"Order"` produces <Order>...</Order>. Without it, the tool uses the struct type name as the root: same default as xml.Marshal.
How does it handle pointers, slices, and maps?
A nil pointer gives an empty element, unless the tag has ,omitempty, which drops it. A slice of structs repeats its element at the same level, like xml.Marshal does, unless the tag uses the Items>OrderItem form, which adds the <Items> parent. encoding/xml refuses to marshal a map at all; this tool writes each key as a child element containing its value, which you can reshape by hand if your schema wants something else.
Is my code stored?
The struct definitions are sent to the backend, which replies with XML. That exchange is not stored, and the page forgets your input when you leave. If the struct sits next to secrets, such as a DSN or a token in a const block, paste just the types and the literal you care about.
What if the struct uses types encoding/xml does not support: channels, funcs, complex?
At runtime xml.Marshal stops with an unsupported type error on a chan, a func or a complex128. This tool keeps going instead: such a field is written as an empty tag while its sibling fields convert normally. It reads source rather than compiling it, so run go vet first if the output looks off.
Other tools you may need
Once a Go struct is XML, these pages help you check the result, go back to Go types from an XML sample, or produce the JSON form for a REST endpoint: