WebToolsPlanet
Converter Tools

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

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What 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

1

Paste one or more SQL INSERT statements.

2

Optionally override the root element (default: table name).

3

Set the row element name (default: row).

4

Pick indent and toggle the XML declaration.

5

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.

SQL input
INSERT INTO users (id, name) VALUES (1, 'Alice');
XML output
<?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.