Home › Developer Tools › JSON to XML Converter

JSON to XML Converter

Paste JSON and get clean, well-formed XML instantly. Choose the root element name, map @ keys to attributes, decide how arrays are written, then copy or download the result. Nothing leaves your browser.

Last updated:

XML output

      
Converts automatically as you type.
Advertisement
Advertisement

How to use the JSON to XML Converter

  1. Paste your JSON into the left box, upload a .json file, or click Sample.
  2. Set the root element name. If your JSON has a single top-level key, it can be used as the root automatically.
  3. Choose how arrays are written: repeated elements with the key's name (<tag>a</tag><tag>b</tag>) or wrapped in a parent with item elements.
  4. Add attributes by prefixing keys with @, for example {"book": {"@id": "b1", "title": "…"}}.
  5. Copy or download the XML.

How JSON is mapped to XML

JSONXML
{"name": "Ann"}<name>Ann</name>
{"user": {"@id": 7, "name": "Ann"}}<user id="7"><name>Ann</name></user>
{"price": {"@currency": "EUR", "#text": 9.5}}<price currency="EUR">9.5</price>
{"tag": ["a", "b"]}<tag>a</tag><tag>b</tag>
{"tag": ["a", "b"]} with Wrap arrays<tag><item>a</item><item>b</item></tag>
{"note": null} or {"note": ""}<note/>
{"#cdata": "a < b"}<![CDATA[a < b]]>
{"#comment": "generated"}<!--generated-->

Numbers and booleans are written as text (44.95, true) because XML has no data types of its own; a schema (XSD) is what gives XML values a type. An empty array produces no element at all, since XML has no way to say "an empty list" without a wrapper.

Tips for clean XML

  • Pick meaningful names. Rename the root and array item elements to match your domain, for example catalog and book.
  • Use attributes for metadata such as IDs, units and language codes, and elements for the actual content.
  • Namespaces can be added with an attribute key such as "@xmlns": "urn:example" or "@xmlns:xsi".
  • Going the other way? Use the XML to JSON converter, and tidy existing XML with the XML Formatter.

Frequently asked questions

How does JSON map to XML?

Each object key becomes an element, its value becomes the element's content, and nested objects become nested elements. Keys that start with @ become attributes, a #text key becomes the element's text, and null becomes an empty element such as <name/>.

How are JSON arrays converted to XML?

By default every array item becomes a repeated element with the array's key as its name, so {"tag": ["a", "b"]} becomes <tag>a</tag><tag>b</tag>. Tick 'Wrap arrays' to get <tag><item>a</item><item>b</item></tag> instead. Arrays at the top level always use the item name.

Why does XML need a root element?

A well-formed XML document must have exactly one root element. If your JSON is an array or an object with several top-level keys, the converter wraps everything in the root name you choose (default root).

What happens to keys that are not valid XML names?

XML element names cannot start with a digit or contain spaces and most symbols. Such characters are replaced with underscores and names that start with a digit get an underscore prefix, for example "2024 sales" becomes <_2024_sales>. The status bar tells you how many names were changed.

Are special characters escaped?

Yes. &, < and > are escaped in text, and quotes are escaped in attribute values, so the output is always well-formed. Control characters that XML 1.0 does not allow are removed.

Is my data uploaded?

No. The conversion runs entirely in your browser with JavaScript, so your JSON is never sent to a server.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

XML to JSONConvert XML to JSON with validation.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.XML FormatterBeautify, validate and minify XML with a collapsible tree view.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.XML to XSD GeneratorGenerate an XML Schema (XSD) from sample XML: types, occurrences, attributes and namespaces.XSD to XML Sample GeneratorGenerate a sample XML document from an XSD schema, with types, attributes and namespaces.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.cURL to Code ConverterConvert curl commands to JavaScript fetch, Axios, Python requests, Node.js, PHP and Go code.Code to ImageTurn code into a beautiful syntax-highlighted PNG with themes, window frame and background.Excel to JSON ConverterConvert Excel sheets (XLSX, XLS, ODS) to JSON with header row, type and shape options.CSV to Excel ConverterConvert CSV files to a real .xlsx workbook with typed numbers and dates, one sheet per file.CSV SplitterSplit a large CSV into smaller files by row count, file count or column value, header kept.CSV MergerCombine many CSV files into one, matching columns by name, with dedupe and a source column.VCF to CSV ConverterConvert vCard (.vcf) contacts to CSV for Google or Outlook, or turn a CSV back into a VCF.Calendar Event (.ics) GeneratorCreate an .ics calendar invite with time zone, reminders and repeats + Google/Outlook links.CSV Column ExtractorPick, reorder and rename CSV columns, filter rows by value, and export a new CSV or JSON.CSV Diff CheckerCompare two CSV files by key column and see added, removed and changed rows cell by cell.CSV Duplicate Row RemoverRemove duplicate rows from a CSV by all or selected columns and download the cleaned file.CSV to HTML TableTurn CSV into clean HTML table code with a live preview, styling options and one-click copy.CSV to Markdown TableConvert CSV to a neatly aligned GitHub Markdown table with column alignment and live preview.CSV TransposeSwap rows and columns of CSV, TSV or pasted spreadsheet data, with delimiter auto-detect.Date Format ConverterConvert any date to ISO 8601, RFC 2822, Unix time and custom strftime, moment or Java patterns.ENV to JSON ConverterConvert .env files to JSON or YAML and JSON back to .env, with quotes and multiline values.File to Base64Convert any file to a Base64 string or data URI with MIME detection, line wrap and download.HTML Table to CSVExtract any table from HTML or page source to CSV, TSV or JSON, with colspan and rowspan handled.IEEE 754 Floating Point ConverterConvert decimals to 32/64-bit IEEE 754 floats: toggle bits, see hex, exact value and rounding error.INI to JSON ConverterConvert INI and CFG files to JSON and JSON back to INI, with sections, arrays and types.IP Address ConverterConvert IPv4 to decimal, hex, binary, octal and back, with class and private/public check.ISBN Converter & ValidatorConvert ISBN-10 to ISBN-13 and back, validate check digits and hyphenate, one or in bulk.JSON Flatten / UnflattenFlatten nested JSON to dot or bracket path keys, or unflatten flat keys back to nested JSON.JSON to Dart ClassTurn JSON into Dart model classes with fromJson, toJson, null safety and nested classes.JSON to Java ClassTurn JSON into Java POJOs or records with Lombok, getters/setters and Jackson or Gson annotations.JSON to Kotlin Data ClassTurn JSON into Kotlin data classes for kotlinx.serialization, Gson, Moshi or Jackson.JSON to Markdown TableTurn a JSON array of objects into a GitHub Markdown table with column picker and alignment.JSON to PHP ArrayConvert JSON to PHP array code (short [] or array()) and PHP arrays back to JSON.JSON to Rust StructTurn JSON into Rust structs with serde derives, rename attributes, Option and Vec types.JSON to SQL ConverterConvert a JSON array of objects to CREATE TABLE and INSERT statements for MySQL, Postgres, SQLite.
See all 129 Data & File Format Converters →