How it works
How to use the XML to C++
Paste XML
Paste an XML document or open a file. Attributes and child elements become fields; repeated elements become lists.
Tune the output
Set the root type name and language-specific options. Nested objects get their own types named after their keys.
Use the C++ code
Decode with auto order = nlohmann::json::parse(text).get<Order>();
How the C++ code is generated
The XML is analysed value by value. Objects inside the same array are merged, so a property that appears only in some items becomes optional, values that are sometimes null become nullable, and identical nested shapes share a single type. Names are converted to C++ conventions, with serialization annotations wherever the original key differs.
For XML input, the document is first converted to a JSON structure: attributes and child elements become properties, element text becomes a text property, and repeated elements become arrays.
Usage: Decode with auto order = nlohmann::json::parse(text).get
Built for developers
Why developers use it
Private by design
Runs 100% in your browser. Nothing you paste is uploaded, logged or stored on a server.
Instant results
Output updates as you type, with precise error locations when something is wrong.
Works offline
Once loaded, the tool keeps working without a connection. Install it as an app if you like.
Free, no sign-up
No accounts, no limits, no watermarks.
FAQ
Frequently asked questions
How are optional and nullable fields detected?
A property that is missing from some objects in an array is optional; a property that is null in the sample is nullable. The more representative your sample, the more accurate the types.
What happens with mixed types?
Values with different types in different samples become a union where C++ supports it, or the language's generic "any JSON value" type otherwise.
Is my data uploaded anywhere?
No. Everything runs locally in your browser — nothing you paste or open is sent to a server, logged or stored. The tool keeps working offline once the page has loaded.
Keep going
Related tools
- JSON to C++Generate C++ classes from JSON
- XML to JavaGenerate Java classes from XML
- XML to C#Generate C# classes from XML
- XML to TypeScriptGenerate TypeScript classes from XML
- XML to JSON SchemaGenerate JSON Schema from XML
- XML to PythonGenerate Python classes from XML
- JSON to XMLConvert JSON to XML and XML to JSON
- XML to JSONConvert XML to JSON and back