Convert JSON to XML Online
Convert a JSON array of objects into XML, with one <row> per object. The JSON is parsed in your browser and never uploaded.
Drop a CSV or Excel file here
CSV · XLSX · XLS · XLSM · XLSB
Ready to download as a binary file.
How to convert JSON to XML
Three steps from events.jsonl to XML.
1. Paste the JSON
Paste JSON or drop a .json file. Arrays, keyed objects and JSON Lines all work.
2. Check it in the grid
Check the column names: ts, level and msg become tag names. Rename them in the grid (timestamp, severity, message) if the receiver expects other elements.
3. Name the tags
Set the root and row tag names, choose elements or attributes, toggle pretty printing, then copy or download data.xml.
Example: JSON in, XML out
Log events in JSON Lines format (one object per line), with a < character in a message.
{"ts":"2024-05-02T10:00:00Z","level":"info","msg":"started"}
{"ts":"2024-05-02T10:00:03Z","level":"warn","msg":"disk < 10%"}<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<ts>2024-05-02T10:00:00Z</ts>
<level>info</level>
<msg>started</msg>
</row>
<row>
<ts>2024-05-02T10:00:03Z</ts>
<level>warn</level>
<msg>disk < 10%</msg>
</row>
</rows>Each JSON line becomes one <row>, and the < in "disk < 10%" is written as <.
What changes between JSON and XML
Tag names come from headers
Column elements are named after the headers (<ts>, <level> and <msg>). Spaces and symbols would become _, and a header starting with a digit would get a col_ prefix.
Text only
Every value is element text, escaped for XML (& < > " '). No types or schema are written.
JSON Lines
The text is not one JSON value, so each line is parsed as an object of its own and becomes one row.
When to convert JSON to XML
- Feeding JSON from a modern API into a system that only accepts XML.
- Producing an XML file to match a partner's import format.
JSON to XML in JavaScript
JSON needs no parser: JSON.parse gives you the data. Then headers become tag names and values are escaped for XML.
import { readFile } from 'node:fs/promises';
const items = (await readFile('events.jsonl', 'utf8')).split('\n').filter(Boolean).map((line) => JSON.parse(line));
const toText = (v) => (v == null ? '' : typeof v === 'object' ? JSON.stringify(v) : String(v));
const header = [...new Set(items.flatMap((o) => Object.keys(o)))];
const rows = items.map((o) => header.map((key) => toText(o[key])));
const tag = (h) => String(h).trim().replace(/[^A-Za-z0-9_]/g, '_');
const esc = (v) => String(v ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
console.log('<?xml version="1.0" encoding="UTF-8"?>\n<rows>\n' + rows.map((row) =>
' <row>\n' + header.map((h, i) => ` <${tag(h)}>${esc(row[i])}</${tag(h)}>`).join('\n') + '\n </row>'
).join('\n') + '\n</rows>');TabularJS reads spreadsheet files, not JSON; JSON.parse is all JSON needs.
Frequently asked questions
Does it build nested XML from nested JSON?
No. The converter works on a table, so the data is one level deep and nested values are kept as JSON text. For deep structures, a dedicated JSON-to-XML library is the better tool.
Can I convert JSON Lines from a log file?
Yes. Paste the lines: each line holding a JSON object becomes a <row>, and blank lines are skipped. Every non-blank line must be an object.
What if the objects have different keys?
Every key that appears in any object becomes a column. Objects without that key get an empty cell, which becomes an empty element.
Does it generate an XSD schema?
No. The output is plain data XML and every value is text. If the receiver needs a schema, write it to match the tag names you see here.
Does events.jsonl get uploaded when I convert it to XML?
No. The JSON is parsed in your browser and never uploaded.