How does Crystal handle XML?
Crystal ships with the standard-library XML module — require "xml" and call XML.parse(string) to get an XML::Node. From there you walk children with node.first_element_child, node.children, and access attributes via node["id"]. There is no built-in XML mapping macro analogous to JSON::Serializable; community shards like xml_mapping.cr fill that gap. The generator emits a plain class so you can wire up either approach.
Are Crystal types statically inferred?
Yes. Crystal is statically typed with whole-program inference — every property declaration carries an explicit type (String, Int32, Float64, Bool, or a nested class). The generator picks Int32 for integers and Float64 for decimals; switch to Int64 if your XML carries values outside the 32-bit range.
Why snake_case property names?
Crystal style — like Ruby — favors snake_case for methods, properties, and local variables, reserving CamelCase for class names. The generator converts XML element/attribute names from kebab-case or camelCase into snake_case automatically. If your XML uses snake_case already the names round-trip unchanged.
How are XML attributes distinguished from elements?
Both attributes and child elements become properties on the generated class, but attributes carry a "# attribute" comment above the property declaration. When you populate the class from XML::Node, attributes are accessed with node["id"] while child elements are accessed with node.first_element_child or node.children.find — the comment hints which idiom applies.
How are repeated elements like <tag> represented?
Repeated child elements become an Array(T) property. Crystal arrays are statically typed, so the generator emits Array(Tag) and a default Array(Tag).new initializer — no runtime cast required when you append, and the compiler enforces that every push is the right element type.
Does the output use property or getter / setter?
The generator emits property field : Type — the property macro creates both a reader (foo) and a writer (foo=) in one line, which is the idiomatic Crystal pattern. If you only need a reader, change property to getter; for a writer-only field use setter (rare for XML data classes).
Is the XML I paste sent to your servers?
No. XML is parsed by the browser DOMParser and the Crystal source is generated entirely in JavaScript on your machine. Open DevTools → Network and you will see no requests when you click Convert. Safe for SOAP responses and configuration files containing API keys or credentials.
How do I parse XML into the generated Crystal class?
Use require "xml"; node = XML.parse(xml).first_element_child.not_nil!; book = Book.new; book.id = node["id"]; book.title = node.first_element_child.try(&.content) || ""; — repeated for each field. For repeatable population use the xml_mapping.cr shard which adds a use_xml_mapping macro that wires fields automatically based on a DSL.