XML to JSON Converter
Pricing
$0.20 / 1,000 completed conversions
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é
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
a day ago
Last modified
Categories
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,
@attributesby 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, so10.50becomes10.5.
▶️ Run a quick test or a full batch
- Open the Actor input.
- Add one or more items in
Conversion tasks. - Paste XML or JSON into
Pasted XML or JSON, or add a public XML or JSON address inPublic XML or JSON URL. - Keep
Conversion directiononDetect automatically, or chooseXML to JSONorJSON to XMLwhen you need one format. - Keep
Readable outputon for easier inspection, or turn it off for compact XML output. - Set
XML root elementandXML array item elementwhen you are converting JSON to XML. - 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
| Field | Type | What it does |
|---|---|---|
tasks | array of objects | List of conversion tasks. Each task needs inputData, inputUrl, or both. Blank tasks are skipped. Tasks past the run's limit are not converted. |
inputData | string | Pasted XML or JSON text for one task. When it has text, inputUrl in the same task is not used. |
inputUrl | string | Public http or https address of an XML or JSON file. Files that need a login do not work. |
direction | string | Per 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. |
attributesKey | string | The 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. |
alwaysUseLists | boolean | When 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. |
prettyPrint | boolean | Keeps converted XML readable when true, which is the default. Set it to false for compact XML. Applies to JSON-to-XML tasks. |
rootElement | string | Root element name for JSON-to-XML output. The default is root. |
arrayItemElement | string | Element 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
httporhttpsURLs. - 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
| Field | Type | What it does |
|---|---|---|
sourceUrl | string or null | Public URL used for the task, or null when pasted data was used. |
inputPreview | string | Short preview of the submitted or fetched input, so you can match each result to its task. |
convertedJson | object or null | Structured JSON value for XML-to-JSON tasks. null for JSON-to-XML tasks. |
convertedJson.<element>.@attributes | object | The attributes of an XML element, under the key set in attributesKey. |
convertedXml | string or null | XML string for JSON-to-XML tasks. null for XML-to-JSON tasks. |
convertedFileUrl | string | Link 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. UseinputPreviewandsourceUrlto 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 as0x1F, exponent values such as1e5, and very large or very small values such as12345678901234567890123or0.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
#textvalue 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.jsonor.xmlfile. - Each task can set
directionto 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
attributesKeyinput 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
alwaysUseListsinput 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 🫡
🔗 Related Actors
- RSS Feed Reader ↗: Read public RSS, Atom, RDF, and JSON Feed URLs as one dataset row per feed item.
- JSON to CSV Converter ↗: Turn converted JSON into a CSV or TSV file for Excel or another spreadsheet.
- YAML Validator & Converter ↗: Check YAML, JSON, and TOML config files for syntax errors, then convert valid files between formats.
- JSON to XML & XML to JSON Converter ↗: Convert a pasted API response between JSON and XML in either direction, with attributes kept.
- XML to JSON Converter - Any XML File or Feed to Clean JSON ↗: Convert XML sitemaps and RSS feeds by URL into clean JSON, with repeated elements returned as arrays.
Made with ❤️ by Maxime Dupré


