XML to JSON Converter avatar

XML to JSON Converter

Pricing

$0.20 / 1,000 completed conversions

Go to Apify Store
XML to JSON Converter

XML to JSON Converter

Convert XML to JSON and JSON to XML from pasted data or public URLs. Run one task or several tasks in one run, then export structured JSON, XML strings, source URLs, and input previews from the dataset.

Pricing

$0.20 / 1,000 completed conversions

Rating

0.0

(0)

Developer

Maxime Dupré

Maxime Dupré

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

a day ago

Last modified

Share

🔄 XML JSON converter for batch data conversion

XML JSON Converter helps developers and data teams turn XML into JSON and JSON into XML from pasted text or public URLs. Each result is saved as a clean Apify dataset row that you can query, export, or send to another app.

Use it to:

  • Convert XML API responses into structured JSON for analysis.
  • Convert JSON payloads into XML for legacy systems.
  • Batch-convert feeds, config files, or integration payloads in one run.
  • Match each converted result to its source with the source URL and input preview.
  • Download each converted document as a JSON or XML file.

📦 Converted data that keeps XML details

Each successful conversion is saved as one dataset item. XML-to-JSON tasks return structured JSON in convertedJson, so you can query or export the result without parsing a JSON string yourself. JSON-to-XML tasks return an XML string in convertedXml, including an XML declaration and your chosen root element.

The Actor detects whether each task is XML or JSON, unless you choose the direction for that task. Add one task for a quick conversion, or add several tasks to convert a batch in one run.

What the conversion keeps

  • Preserves XML attributes under a key you choose, @attributes by default.
  • Keeps text and attributes on the same element.
  • Supports nested XML, repeated elements, text nodes, namespace-prefixed names, and common data types such as objects, arrays, strings, numbers, booleans, and nulls where the parser can represent them.
  • Keeps data written with XML namespaces, such as feed extension fields, instead of dropping it.
  • Shows standard escaped characters as the characters they stand for, such as an escaped ampersand reading as an ampersand.

How values are typed

  • In XML-to-JSON output, values with leading zeros, such as the product code 007, stay text. Other numbers become JSON numbers, so 10.50 becomes 10.5.

▶️ Run a quick test or a full batch

  1. Open the Actor input.
  2. Add one or more items in Conversion tasks.
  3. Paste XML or JSON into Pasted XML or JSON, or add a public XML or JSON address in Public XML or JSON URL.
  4. Keep Conversion direction on Detect automatically, or choose XML to JSON or JSON to XML when you need one format.
  5. Keep Readable output on for easier inspection, or turn it off for compact XML output.
  6. Set XML root element and XML array item element when you are converting JSON to XML.
  7. Run the Actor and open the dataset.

For a representative first run, keep the prefilled XML and JSON batch. For a tiny manual test, delete most tasks and leave one XML task plus one JSON task.

⚙️ Input

Add conversion tasks in tasks. Each task can contain pasted data, a public URL, or both. If both are present, the pasted data is used for that task.

Example input

{
"tasks": [
{
"inputData": "<catalog><book id=\"1\"><title>Book 1</title><author>Author 1</author></book></catalog>",
"direction": "auto"
},
{
"inputData": "{\"employees\":[{\"name\":\"Alice 2\",\"role\":\"Engineer\"},{\"name\":\"Bob 2\",\"role\":\"Manager\"}]}",
"direction": "auto"
}
],
"attributesKey": "@attributes",
"alwaysUseLists": false,
"prettyPrint": true,
"rootElement": "root",
"arrayItemElement": "item"
}

This example is the public input of a default run. It uses the two prefilled tasks and the default settings.

Input fields

FieldTypeWhat it does
tasksarray of objectsList of conversion tasks. Each task needs inputData, inputUrl, or both. Blank tasks are skipped. Tasks past the run's limit are not converted.
inputDatastringPasted XML or JSON text for one task. When it has text, inputUrl in the same task is not used.
inputUrlstringPublic http or https address of an XML or JSON file. Files that need a login do not work.
directionstringPer task. auto (shown as Detect automatically, the default), xmlToJson (XML to JSON), or jsonToXml (JSON to XML). If you choose one, a document in the other format fails for that task.
attributesKeystringThe JSON key that holds an XML element's attributes. The default is @attributes. Pick a name that no XML element uses. JSON-to-XML tasks use the same key to turn values back into attributes.
alwaysUseListsbooleanWhen true, every child XML element goes in a list, even when it appears only once. The default is false. Applies to XML-to-JSON tasks.
prettyPrintbooleanKeeps converted XML readable when true, which is the default. Set it to false for compact XML. Applies to JSON-to-XML tasks.
rootElementstringRoot element name for JSON-to-XML output. The default is root.
arrayItemElementstringElement name for each item when the top level of a JSON-to-XML task is an array. The default is item. Arrays inside objects keep their own key names.

Private or authenticated files should be fetched outside the Actor and pasted into inputData. The Actor does not accept cookies, source credentials, or API keys for source URLs.

Limits and caveats

  • The Actor is a deterministic converter. It does not use AI, repair invalid XML or JSON, infer schemas, convert CSV/YAML/HTML, crawl websites, or access private URLs that require login.
  • Source URLs must be public http or https URLs.
  • Each run has a task limit. Tasks past that limit are not converted.
  • A public address that cannot be read is skipped, and the run log gives the reason. An address that returns an empty file is skipped with a warning. Unreachable addresses can make a run take longer.
  • Private URLs, signed URLs that expire, login-only files, cookies, and source credentials are not supported.
  • Invalid tasks are skipped, and each one is reported as a warning in the run log.
  • The Actor does not repair malformed XML or JSON. For XML, it only checks that the document can be read as XML. It does not check the document against an XML schema or business rules.
  • JSON-to-XML element names come from your rootElement, arrayItemElement, and JSON object keys, so use XML-safe names.
  • This is not a universal data converter. CSV, TSV, YAML, HTML table extraction, and website crawling are outside this Actor.

🧾 Output

Each dataset item is one successful conversion.

Output fields

FieldTypeWhat it does
sourceUrlstring or nullPublic URL used for the task, or null when pasted data was used.
inputPreviewstringShort preview of the submitted or fetched input, so you can match each result to its task.
convertedJsonobject or nullStructured JSON value for XML-to-JSON tasks. null for JSON-to-XML tasks.
convertedJson.<element>.@attributesobjectThe attributes of an XML element, under the key set in attributesKey.
convertedXmlstring or nullXML string for JSON-to-XML tasks. null for XML-to-JSON tasks.
convertedFileUrlstringLink to download the converted document as a file. It is a .json file for XML-to-JSON tasks and an .xml file for JSON-to-XML tasks.

These rows come from the default run above. The access signature in each file link is replaced with ....

XML to JSON row

{
"sourceUrl": null,
"inputPreview": "<catalog><book id=\"1\"><title>Book 1</title><author>Author 1</author></book></catalog>",
"convertedJson": {
"catalog": {
"book": {
"title": "Book 1",
"author": "Author 1",
"@attributes": {
"id": 1
}
}
}
},
"convertedXml": null,
"convertedFileUrl": "https://api.apify.com/v2/key-value-stores/1i2H07hk0gwCZ9Emq/records/conversion-1.json?signature=..."
}

JSON to XML row

{
"sourceUrl": null,
"inputPreview": "{\"employees\":[{\"name\":\"Alice 2\",\"role\":\"Engineer\"},{\"name\":\"Bob 2\",\"role\":\"Manager\"}]}",
"convertedJson": null,
"convertedXml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n <employees>\n <name>Alice 2</name>\n <role>Engineer</role>\n </employees>\n <employees>\n <name>Bob 2</name>\n <role>Manager</role>\n </employees>\n</root>\n",
"convertedFileUrl": "https://api.apify.com/v2/key-value-stores/1i2H07hk0gwCZ9Emq/records/conversion-2.xml?signature=..."
}

💳 Pricing

The Actor charges only for successful conversions. Invalid XML, invalid JSON, empty tasks, unreachable URLs, and unsupported URLs do not save dataset items, so they are not charged.

Each successful conversion costs $0.0002 and is billed as "Completed conversion". The pricing has no separate charge for starting a run. If you set a maximum spend for a run, the Actor stops starting new conversions once that limit is reached.

🔌 Integrations

Send results to other tools with these Apify features:

  • Read the dataset through the Apify API.
  • Use Apify webhooks to notify another app when a run finishes.
  • Export the dataset as JSON, CSV, Excel, XML, RSS, or HTML from Apify.

Watch the video

❓ FAQ

Why do values such as 007 stay as text?

Values with leading zeros stay text, so product codes keep their leading zeros.

What happens to XML attributes?

They are kept in the converted JSON under the key set in attributesKey. The default is @attributes. Pick a name that no XML element uses.

Are XML namespaces kept?

Yes. Data written with XML namespaces, such as feed extension fields, is kept instead of dropped.

What happens when a document declares custom entities?

The Actor refuses that document and gives a clear reason. It does not expand the custom entities.

What happens when XML is malformed?

The Actor does not repair it or return a guessed result. The task is skipped, and the run log says what is wrong.

What happens when one task is invalid?

The invalid task is skipped, a warning is logged, and the rest of the batch continues. Only successful conversions are saved to the dataset.

What happens if nothing is saved?

If nothing is saved and a public address could not be fetched, the run is marked as failed, and the log says why. For example, the address may have been blocked, rate limited, or timed out. If nothing is saved because every task is invalid, the run finishes with a warning and is not marked as failed.

Do failed tasks cost money?

No. Only saved successful conversions are charged. Invalid, empty, and unreachable tasks do not save a dataset item, so they are not charged.

Does it support authenticated URLs?

No. For private or authenticated files, fetch the content yourself and paste it into inputData.

Can this convert XML to JSON from a URL?

Yes. Add a public XML URL in inputUrl. The output is saved in convertedJson.

Can this convert JSON to XML?

Yes. Paste JSON or add a public JSON URL. The output is saved in convertedXml.

Do I need to choose XML to JSON or JSON to XML?

No. Each task detects its format by default. If you choose XML to JSON or JSON to XML for a task, a document in the other format fails for that task.

Is there an online XML to JSON converter?

Yes. Open the Actor in Apify Console, paste XML or add a public XML URL, and start a run. The results appear in the dataset.

📝 Changelog

v1.0 (13-10-2026)

  • Breaking: Dataset items no longer include taskIndex. Use inputPreview and sourceUrl to match each item to its input.
  • Breaking: Some number-like values now stay text instead of becoming numbers. This covers values with leading zeros, such as 007, hex values such as 0x1F, exponent values such as 1e5, and very large or very small values such as 12345678901234567890123 or 0.0000001. This applies to attribute values too.
  • Breaking: XML declarations, such as <?xml version="1.0"?>, and processing instructions no longer appear as keys in the converted JSON.
  • Breaking: Blank space between elements no longer appears as a #text value in the converted JSON.
  • Breaking: XML that declares custom entities is now refused with a reason.
  • Breaking: A run fails when it saves no results and a public address was still busy, not responding, or blocking access after all retries. The run log gives the reason.
  • Public XML files that declare another text encoding, such as UTF-16 or ISO-8859-1, are now read in that encoding.
  • When a website is busy, does not respond, sends an empty answer, or shows a block page, the Actor tries that public address again several times before it skips the task. Addresses that keep failing can make a run take longer.
  • Public gzip files are unpacked before they are converted.
  • Each dataset item includes convertedFileUrl, a link to download the converted document as a .json or .xml file.
  • Each task can set direction to detect the format automatically, convert XML to JSON, or convert JSON to XML. If the document is in the other format, that task fails with a reason.
  • The new attributesKey input sets the key for XML attributes, such as @attributes. It applies to both conversion directions.
  • A task fails with a reason when an XML element has the same name as the attributes key. A JSON-to-XML task also fails when a value under that key is not an object, or when the XML it would create is not valid, such as when a JSON key contains a space or an attribute value is true.
  • The new alwaysUseLists input puts every child XML element in a list, even when it appears only once. It is off by default.
  • In the input form, each conversion task now has its own fields, instead of one JSON text box for all tasks.
  • Memory now ranges from 128 MB to 256 MB, with 128 MB as the default. Earlier versions ranged from 512 MB to 1024 MB, with 512 MB as the default.
  • The starter input has two sample tasks instead of 4,096 prefilled tasks.
  • When a run is stopped early, the Actor finishes saving the item in progress, skips the other tasks, and does not charge for them.

v0.0

  • Initial release.

🆘 Support

For issues, questions, or feature requests, file a ticket and I'll fix or implement it in less than 24h 🫡

Made with ❤️ by Maxime Dupré