SQL to XML Converter
This SQL to XML converter reads INSERT … VALUES statements and writes each row as an XML element, with one child element per column taken from the statement column list. The table name becomes the wrapper element unless you rename it. Column names that are not valid XML element names — ones containing spaces or starting with a digit — are rewritten with underscores so the document always parses, and text content is escaped so an ampersand or an angle bracket in your data cannot break the markup. Statements are tokenised rather than pattern-matched, so escaped quotes and commas inside string literals are handled correctly.
How it works
Each inserted row becomes one element, with a child element per column taken from the statement column list. The table name is used as the wrapper element unless you override it.
Column names that are not valid XML names are rewritten with underscores, and text content is escaped, so the document always parses.
The conversion runs entirely in your browser — nothing you paste or upload is sent to a server.
How to convert SQL to XML
- Paste your
INSERTstatements into the input on the left, or upload a.sqldump. - Rename the wrapper and row elements if the schema you are feeding expects particular names.
- Copy the XML, or download it as an
.xmlfile.
How the document is shaped
Each inserted row becomes one element, with a child element per column taken from the statement's column list. The
table name is used as the wrapper element by default, so a dump of a users table produces
<users> containing repeated <row> elements.
Column names XML will not accept
Database column names are far more permissive than XML element names. A column called order total or
2026_forecast is perfectly legal in SQL and would produce a document that fails to parse. Invalid
characters are replaced with underscores and a leading digit gets an underscore prefix, so the output is always
well formed.
Escaping
Values are escaped as entities, so a column holding R&D or an HTML fragment cannot break the
markup. NULL becomes an empty element, which is the closest XML equivalent to an absent value.
Common use cases
- Building a SOAP request body from rows you already have.
- Feeding a legacy system that only accepts XML imports.
- Producing fixtures for an XML-based integration test.
Frequently asked questions
How do I convert SQL to XML?
Paste your INSERT statements into the left panel or upload a .sql file. The XML document appears on the right, ready to copy or download.
What are the elements named?
The wrapper element defaults to the table name from the statement and the row element to "row". Both can be renamed to match whatever schema you are feeding.
What if a column name is not a valid XML name?
It is repaired. Invalid characters become underscores and a leading digit gets an underscore prefix, because XML element names cannot start with a number.
Is my data escaped?
Yes. Ampersands, angle brackets and quotes inside values are escaped as entities, so no value can accidentally be read as markup.
How is NULL represented?
As an empty element, which is the closest XML equivalent to an absent value.
Does anything leave my browser?
No. The conversion is entirely local.
Related tools
SQL to JSON Converter
This SQL to JSON converter reads INSERT statements and gives you an array of typed records.
SQL to YAML Converter
This SQL to YAML converter turns inserted rows into a list of mappings, ready for fixtures.
XML to JSON Converter
This XML to JSON converter parses XML into JSON online, preserving attributes and repeated tags as arrays.