SQL to XML Converter
Paste SQL INSERT statements and get well-formed XML with configurable root and row element names, NULL handled as `xsi:nil`, and proper escaping.
Last updated: May 27, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is SQL to XML Converter?
Many legacy and enterprise systems still consume XML. Migrating data out of a SQL system into one of those consumers usually means converting INSERT statements to XML — a tedious task when done by hand.
This tool parses INSERT statements with a real SQL tokenizer and emits well-formed XML. The root element defaults to the table name (overridable), and each row becomes an element you can name (default `<row>`). Column values become child elements with the column name. NULL values render as `<col xsi:nil="true"/>` instead of empty elements, which most XML consumers treat as "missing" rather than "empty string". Special characters in element names are sanitized.
How to Use SQL to XML Converter
Paste one or more SQL INSERT statements.
Optionally override the root element (default: table name).
Set the row element name (default: row).
Pick indent and toggle the XML declaration.
Copy the XML output.
Common Use Cases
- Converting a SQL export to XML for a legacy ESB or SOAP service.
- Producing XML fixtures from a SQL dump.
- Migrating data into XML-based file formats.
- Quickly inspecting a SQL INSERT as XML for debugging.
Example Input and Output
A SQL INSERT becomes XML with table name as root and row as row element.
INSERT INTO users (id, name) VALUES (1, 'Alice');<?xml version="1.0" encoding="UTF-8"?>
<users>
<row>
<id>1</id>
<name>Alice</name>
</row>
</users>Privacy
All parsing happens in your browser. No SQL is sent to a server.
XML namespaces
The output uses xsi:nil for NULL values but does not declare the xsi namespace. Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" to the root element if your consumer is strict about namespaces.
Frequently Asked Questions
Why is NULL rendered as xsi:nil?
Empty <col></col> means "the value is an empty string", which is different from NULL. Using <col xsi:nil="true"/> follows the W3C XML Schema instance convention to signal absence.
What if my column name has special characters?
XML element names cannot start with a digit or contain spaces. The tool sanitizes such names by replacing invalid characters with underscores and prefixing a digit-leading name with _.
Does this support SELECT result output?
Only INSERT statements. Save SELECT results as INSERT from your database client and paste them here.
Does this send my SQL anywhere?
No. All parsing happens locally in your browser.
Related Tools
SQL to JSON Converter
Parse SQL INSERT statements and output the rows as JSON objects. Handles quoted identifiers, escaped strings, NULL, TRUE/FALSE, and multiple rows per statement.
SQL to CSV Converter
Parse SQL INSERT statements and produce a CSV table. Supports comma, semicolon, pipe, and tab delimiters with proper RFC 4180 quoting.
SQL to HTML Converter
Parse SQL INSERT statements and render them as an HTML table — with the table name as a caption, configurable CSS class, and optional inline styles.
JSON to XML Converter
Convert JSON to XML online. Nested objects and arrays are mapped to XML elements with configurable root element name and optional XML declaration.
XML Beautifier
Format and prettify minified or messy XML with configurable indentation. Also minify XML to remove whitespace.
SQL Formatter
Format, minify, convert, compare, and analyze SQL queries in a private browser-based SQL formatter with MySQL and PostgreSQL workflow tools.

