CSV to XML and JSON Converter
CV-98Paste CSV and press CSV to XML or CSV to JSON. Each row becomes an element or an object, keyed by the header row.
Runs in your browser. Nothing is uploaded.
CSV (optional first lines for XML: -- root: name, -- row: name)
XML or JSON
How to use it
- Paste your CSV, or open a file.
- Leave the delimiter on Auto, or pick comma, semicolon, tab or pipe.
- Set the root and row element names for XML, or tick the number option for JSON.
- Press CSV to XML or CSV to JSON, then copy or download.
Two outputs from one input
The same CSV feeds both buttons, so you can compare the two shapes without pasting twice. XML gets a root element, one row element per record, and a child element per column. JSON gets an array of objects with the header names as keys. If the first row is not a header, turn that option off and the columns are named column_1, column_2 and so on.
What changes in your data
XML names must be valid, so header text such as "first name" becomes first_name, and duplicate headers get _2 and _3. In JSON every value is a string unless you tick the number option, which turns whole numbers up to 15 digits, decimals, true and false into real types and empty cells into null. Longer integers and values with leading zeros stay text, so nothing is rounded.
Naming the XML elements
The drop-down lists cover common names. For anything else, put a line such as -- root: orders on the first line of the input and -- row: order on the next. Those lines are read and removed before conversion and override the lists. Neither output writes XML attributes.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
No rows found in the CSV. | The input has no data rows. | Paste at least a header and one row. |
A quoted field is never closed (missing closing ") | A field starts with a double quote but never ends with one. | Close the quote, or double it ("") where it belongs to the text. |
Questions people ask
How do I convert CSV to XML?
Paste the CSV and press CSV to XML. Each row becomes a row element and each column a child element named after the header. Use -- root: and -- row: lines at the top of the input to choose the names.
Will numbers in my CSV stay numbers in JSON?
By default every value is a string, so nothing changes silently. Tick the number option to get real numbers and booleans. Integers longer than 15 digits and values like 007 stay text on purpose.
What if my CSV uses semicolons?
Leave the delimiter on Auto, which checks the first line, or choose semicolon by hand. Tab and pipe are also available. Quoted fields with the delimiter inside are read correctly.
Can the XML have attributes?
No. Every column becomes a child element. If you need attributes, convert here and post-process the XML, or build a JSON object with keys that start with @ and use the JSON to XML tool.
How are empty cells handled?
In XML an empty cell becomes an empty element such as <city/>. In JSON it stays an empty string, or becomes null when the number option is ticked. Short rows are padded with empty values.
About this tool
Both buttons read the same CSV. CSV to XML writes one row element per record with a child element per column; header names that are not valid XML names have invalid characters replaced with _, empty cells become empty elements, and everything is text. To set the element names, put -- root: orders and -- row: order on the first lines. CSV to JSON writes an array of objects keyed by the header, with every value as a string unless you tick the number option, which converts whole numbers up to 15 digits, decimals, true and false, and turns empty cells into null. Longer integers and values with leading zeros stay text so nothing is rounded. Duplicate headers get _2, _3, and short rows are padded. Neither side writes attributes.