Random XML Generator
RG-24Make a well-formed XML document for tests in one click: a random tree of the depth you choose, or a list of records with the columns you name.
Runs in your browser. Nothing is uploaded.
Records action only: columns, one per line, as name:type or just type (id, first_name, last_name, name, email, city, word, number, age, decimal, date, boolean, phone, ip, url, text). Empty uses a default set. The tree action ignores this box.
Random XML
How to use it
- For a random tree, pick the root element, depth and most children per element. Tick attributes, comments or CDATA if you want them.
- Press Random XML tree.
- For flat records, list columns in the box as name:type, choose the number of rows and press Records as XML.
- Copy the document or download it as a .xml file.
The random tree
The tree starts with a root element and nests to the depth you choose. Each element has between one and the most children you allow, or exactly that many when Always use the most children is ticked. Element names, attribute names and text come from a short word list, so they are lowercase ASCII and valid XML names. Leaves hold text; other elements hold only child elements. Text is escaped, attribute values are quoted, and the first line is an XML declaration for UTF-8. With depth 5 and 6 children you can get thousands of elements.
Records and limits
Records as XML writes one record element per row inside a records root, with each column as a child element. Column names must be valid XML names, so they must start with a letter or underscore and use only letters, digits, underscores, hyphens and dots; names that begin with xml are refused. The tool makes no schema, namespaces, DTD or mixed content, and it does not validate existing XML. Names and values are made up, so they describe no real people.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Use at most 30 columns. | The box lists more than 30 columns. | Remove some columns. |
Questions people ask
How do I generate random XML for testing?
Choose a depth and the most children per element, then press Random XML tree. For rows that look like database records, list columns in the box and press Records as XML. Both give a complete document with an XML declaration.
Is the generated XML well formed?
Yes. Tags are balanced, names are valid, special characters in text and attributes are escaped, and CDATA sections are closed. The tool does not validate against a schema, because it does not make one.
Can I add attributes and comments?
Yes. Tick Add attributes to give some elements zero to two attributes, and Add comments for random comment lines. Add CDATA sections wraps some leaf text in CDATA, with a small piece of markup inside it.
How big can the document get?
Depth goes up to 5 and children up to 6, so a full tree can reach about 9,300 elements. The defaults, depth 3 and up to 3 children, give a small document. Records go up to 1000 rows with up to 30 columns.
Can I choose my own element names?
In the tree, names are random words, but you can choose the root from root, data, document or catalog. In the records action, your column names become the element names, as long as each is a valid XML name.
Does it support namespaces or a DTD?
No. The output has no namespaces, DTD, processing instructions other than the XML declaration, or mixed text and elements. For validation or conversion, use an XML formatter or a schema tool.
About this tool
Values are made in your browser with crypto.getRandomValues and rejection sampling, so no value is favored, and nothing is sent anywhere or stored. The tree action builds a nested document with the root, depth and child count you pick; element names, attribute names and text come from a short word list written for this page, so they are all lowercase ASCII and valid XML names. Leaves hold text; inner elements hold only child elements. Text is escaped (& < >) and attribute values are quoted. Comments and CDATA sections are added at random when ticked. The records action writes one <record> per row inside <records>, with the columns from the box as child elements (names:type, as in the CSV generator); column names must be valid XML names. No schema, namespaces or DTD are produced, and documents have no mixed content. The first line is always an XML declaration for UTF-8.