Scala to XML Converter
Paste Scala case classes or objects. Get clean XML back.
What this tool does
If you have ever needed an XML payload that matches a Scala case class — for an Akka HTTP fixture, a Play Framework config, a legacy SOAP integration, or a test — you have probably hand-written more XML than you wanted to. Paste the Scala here and get back well-formed XML straight away. A single case class, a populated val, or a whole file with nested types — all of it comes through with every field preserved.
The converter understands how Scala actually looks when it hits XML. BigDecimal literals with a trailing suffix come out as plain numeric text, Option[String] fields map to empty elements when they hold None instead of being dropped silently, List[T] and Seq[T] become container elements with one child per item (named after the element type), and Map[K,V] turns into <Entry><Key/><Value/></Entry> pairs. This matches what scala-xml or jackson-module-scala would emit when you round-trip a model.
Nested case classes expand into nested elements, companion-object constants are ignored, and sealed-trait hierarchies keep the concrete subtype name as the element tag. You can paste several classes at once — the converter preserves the relationships, so if your Order contains a List[OrderItem] and a ShippingAddress, all three come back together. See the official case class tour for a refresher on what gets treated as data vs behaviour.
How to use it
Three steps. Same flow whether you paste a five-line case class or a whole model file.
Paste your Scala (or load the sample)
Drop the code into the left editor as-is. A single case class, a populated val instance, multiple classes, or sealed-trait hierarchies — the parser is happy with all of them. Hit Load Sample if you want to see a realistic example first.
No need to strip imports, remove the package declaration, or clean up Scala syntax. Leave the code the way it looks in IntelliJ or Metals. Just paste.
Hit Convert
Click the green Convert button. The tool parses the case classes, walks the populated instance, and builds the XML in one pass. A short loading indicator runs while it works.
Copy the XML
The right panel fills with indented, well-formed XML that any standards-compliant parser will accept. Copy it straight into your Akka HTTP test, Play XML body, SBT resource file, or wherever you need it.
When this actually comes in handy
Akka HTTP and Play fixtures
You have a case class for an inbound XML request in Akka HTTP or Play and need a realistic body for a test or a curl command. Paste the class, get the XML, drop it into your spec.
XML config for legacy systems
A config case class with 30 fields turns into a ready-to-edit XML template for older platforms that still want XML — Mule, WebLogic, IBM MQ, or in-house tooling.
Documentation that matches the code
Generate XML examples for a README, ScalaDoc, or Confluence page straight from your actual case classes, so the docs never drift from the model.
Test data for SOAP and scala-xml
Turn populated instances from your unit tests into XML seed files for integration tests, WireMock stubs, or systems that still speak SOAP.
Common questions
Can I paste multiple case classes at once?
Yes — paste a whole file. Each top-level case class comes through with nested types expanded and companion-object helpers ignored. If your Order contains a List[OrderItem], both show up in the output with the right nesting.
How does it handle Option, None, and default values?
An Option[String] holding Some("x") becomes a normal element with the text inside. None becomes an empty element so the shape of the XML stays consistent — nothing gets silently dropped. Default values on case class fields are used when a field is missing from the instance.
What about BigDecimal, Instant, UUID, and the funky numeric types?
BigDecimal drops its suffix and comes out as plain numeric text. java.time.Instant, LocalDate, and LocalDateTime become ISO-8601 strings. UUID keeps its standard 8-4-4-4-12 hex format. Primitive wrappers (Int, Long, Double, Boolean) become plain text — the same shape jackson-module-scala emits by default.
Do List, Seq, Set, and Map all work the same way?
Close. List[T], Seq[T], Vector[T], and Set[T] all become container elements with one child per item named after the element type — so Items: List[OrderItem] becomes <Items><OrderItem/><OrderItem/></Items>. Map[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. If the Scala is genuinely sensitive, give it a quick look before pasting, same as with any online tool.
What if the Scala has implicit conversions, type classes, or macros?
Implicits and macro-generated code do not produce XML fields on their own — we work off the declared case class members. So an implicit val format or a @JsonCodec annotation is effectively ignored and the raw field shape comes through. If the code has syntax errors, fix the obvious ones first.
Other tools you may need
Scala to XML is one piece of the puzzle. These tools pair well with it: