VOOZH about

URL: https://apify.com/automation-lab/xml-json-converter

⇱ XML to JSON Converter | JSON to XML Online Tool Β· Apify


Pricing

Pay per event

Go to Apify Store

XML ↔ JSON Converter

πŸ”„ Convert between XML and JSON in both directions. Handles RSS feeds, SOAP responses, config files, and any structured data. Supports attributes, CDATA, arrays, URL input, and bulk processing.

Pricing

Pay per event

Rating

0.0

(0)

Developer

πŸ‘ Stas Persiianenko

Stas Persiianenko

Maintained by Community

Actor stats

0

Bookmarked

3

Total users

0

Monthly active users

2 months ago

Last modified

Share

Instantly convert XML to JSON or JSON to XML β€” bidirectional, fast, and free to try. Handles RSS feeds, SOAP responses, config files, API payloads, and any structured data format. No proxy, no scraping β€” pure computation.


What Does It Do?

The XML ↔ JSON Converter transforms data between XML and JSON formats in both directions:

  • πŸ“„ XML β†’ JSON: Parse any XML document (RSS feeds, SOAP responses, sitemaps, config files) into clean JSON
  • πŸ” JSON β†’ XML: Serialize JSON objects or arrays back into well-formed XML
  • πŸ€– Auto-detect mode: Paste data without specifying the format β€” the actor detects whether it's XML or JSON automatically
  • πŸ”— URL input: Provide a URL to an XML or JSON file β€” the actor fetches and converts it
  • πŸ“¦ Bulk mode: Process multiple conversion tasks in a single run using the inputs array

Data passes through the fast-xml-parser library β€” a battle-tested, high-performance parser used by millions of npm projects.


Who Is It For?

Backend Developers

You're integrating with a legacy SOAP API that returns XML, but your app speaks JSON. This actor handles the translation as a step in your pipeline β€” no custom parsing code required.

Data Engineers & ETL Pipeline Builders

You receive RSS/Atom feeds, Sitemap XML files, or third-party XML exports and need them as JSON for downstream processing in tools like n8n, Make, or Zapier. Feed the URLs in, get JSON out.

No-Code / Low-Code Automators

You're building workflows in n8n or Make and hit a wall because an API returns XML. Drop this actor in as a conversion step and carry on with JSON-native logic.

QA Engineers & API Testers

You're testing SOAP/REST hybrid APIs and need to quickly inspect or transform XML payloads during debugging sessions.

System Administrators

You manage configuration files in XML (pom.xml, web.config, Ant build files) and want them as JSON for tooling, validation, or migration.


Why Use This Actor?

  • ⚑ Instant results β€” pure computation, no browser, no proxy, no scraping delays
  • 🏷️ Attribute preservation β€” XML element attributes are captured under @attributes keys, not lost
  • 🌊 CDATA support β€” CDATA sections are handled natively via the __cdata property
  • πŸ“ Correct array detection β€” repeated sibling XML elements automatically become JSON arrays
  • πŸŽ›οΈ Flexible output β€” pretty-printed or compact, custom root element names, custom array item node names
  • πŸ’Έ Ultra-low cost β€” $0.01 start + $0.0015 per conversion (see Pricing below)
  • πŸ”— URL input supported β€” fetch and convert remote XML/JSON files by URL directly

Extracted Data

Each conversion task produces one output item in the dataset:

FieldTypeDescription
inputIndexNumberTask sequence number (1-based)
modeStringActual conversion mode used: xmlToJson or jsonToXml
outputFormatStringOutput format: json or xml
inputPreviewStringFirst 150 characters of input data
outputStringThe converted output (JSON string or XML string)
errorStringError message if the conversion failed (field absent on success)

How Much Does It Cost to Convert XML to JSON?

Pricing uses Pay-Per-Event β€” you only pay for what you use. There are no monthly subscriptions.

EventFREE PlanBRONZESILVERGOLDPLATINUMDIAMOND
Run start (one-time)$0.010$0.0095$0.0085$0.0075$0.0060$0.0050
Per conversion$0.0015$0.00135$0.0012$0.00098$0.00075$0.0006

Example costs:

  • Convert 1 XML file: ~$0.0115 (start + 1 conversion)
  • Convert 10 XML files in bulk: ~$0.025 (start + 10 conversions)
  • Convert 100 files in bulk: ~$0.160 (start + 100 conversions)

All Apify accounts include a free monthly compute budget to try actors at no charge. The FREE plan pricing applies within that budget.


How to Use the XML ↔ JSON Converter

Step 1: Choose Your Input Method

You can provide input data in two ways:

  1. Paste data directly β€” put your XML or JSON string in inputData
  2. Provide a URL β€” put the URL of an XML or JSON file in inputUrl

Step 2: Select the Conversion Mode

  • Auto-detect (recommended): the actor inspects your input and picks the right direction automatically
  • XML β†’ JSON: explicitly convert XML to JSON
  • JSON β†’ XML: explicitly convert JSON to XML

Step 3: Configure Options

  • Parse XML Attributes: include element attributes in JSON output (under @attributes key)
  • Root Element Name: when generating XML from JSON, wrap output in this root element (default: root)
  • Pretty Print: format output with indentation (recommended for readability)
  • Array Item Node Name: when a JSON array is at the root, wrap each item in this XML element name (default: item)

Step 4: Run and Collect Results

Click Start and the results appear in the Dataset tab. Each conversion task produces one row. Download as JSON, CSV, or use the API.


Input Parameters

ParameterTypeDefaultDescription
inputsArrayβ€”Array of conversion tasks (bulk mode). Each item can override all other settings.
modeStringautoConversion direction: auto, xmlToJson, or jsonToXml
parseAttributesBooleantrueInclude XML attributes in JSON output under @attributes key
rootElementStringrootRoot XML element name when converting JSON β†’ XML
prettyPrintBooleantrueFormat output with indentation and line breaks
arrayNodeNameStringitemXML element name for array items when root is a JSON array

Bulk Mode Input Item

Each item in the inputs array supports:

FieldTypeDescription
inputDataStringRaw XML or JSON string to convert
inputUrlStringURL of an XML or JSON file to fetch and convert
modeStringOverride conversion mode for this task
parseAttributesBooleanOverride attribute parsing for this task
rootElementStringOverride root element for this task
prettyPrintBooleanOverride pretty-print for this task
arrayNodeNameStringOverride array item node name for this task

Output Examples

XML β†’ JSON (with attributes)

Input XML:

<catalog>
<bookid="1">
<title>The Great Gatsby</title>
<author>F. Scott Fitzgerald</author>
<price>9.99</price>
</book>
<bookid="2">
<title>To Kill a Mockingbird</title>
<author>Harper Lee</author>
<price>12.99</price>
</book>
</catalog>

Output JSON:

{
"catalog":{
"book":[
{
"@attributes":{"id":1},
"title":"The Great Gatsby",
"author":"F. Scott Fitzgerald",
"price":9.99
},
{
"@attributes":{"id":2},
"title":"To Kill a Mockingbird",
"author":"Harper Lee",
"price":12.99
}
]
}
}

JSON β†’ XML

Input JSON:

{
"employees":[
{"name":"Alice","role":"Engineer"},
{"name":"Bob","role":"Manager"}
]
}

Output XML (root element: company):

<?xml version="1.0" encoding="UTF-8"?>
<company>
<employees>
<name>Alice</name>
<role>Engineer</role>
</employees>
<employees>
<name>Bob</name>
<role>Manager</role>
</employees>
</company>

Tips and Best Practices

πŸ’‘ Use auto-detect for quick conversions β€” the actor correctly identifies XML (starts with <) vs JSON (starts with { or [) in virtually all cases.

πŸ’‘ Process RSS/Atom feeds via URL β€” put the feed URL in inputUrl and set mode to auto. The actor fetches and converts in one step.

πŸ’‘ Bulk-convert multiple files in one run β€” use the inputs array to process many files in a single run. This saves the start cost compared to launching separate runs for each file.

πŸ’‘ XML attributes are under @attributes β€” when parseAttributes is true (default), element attributes are captured cleanly under a dedicated key, not mixed with child elements.

πŸ’‘ Repeated XML elements become JSON arrays automatically β€” fast-xml-parser detects repeated sibling elements and converts them to arrays. You don't need to configure this.

πŸ’‘ Use compact output for storage β€” set prettyPrint: false for compact output when you're piping the result into another system (saves bandwidth and storage).

πŸ’‘ Set a meaningful rootElement for JSON β†’ XML β€” instead of the generic root, use a domain-specific name like products, orders, or employees to produce readable XML.


Integrations

n8n: Convert XML API Response to JSON

  1. Use an HTTP Request node to call your XML API
  2. Add an Apify node, select XML ↔ JSON Converter
  3. Pass the response body as inputData with mode: xmlToJson
  4. Use the JSON output in downstream nodes

Make (formerly Integromat): Transform Webhook Payloads

  1. Receive an XML webhook payload in a Webhooks module
  2. Call the XML ↔ JSON Converter via Apify's HTTP module
  3. Parse the JSON output with Make's built-in JSON parser
  4. Route to Google Sheets, Slack, or any other module

Zapier: RSS Feed to Structured Data

  1. Trigger on a schedule with Zapier Schedule
  2. Use Webhooks by Zapier to call the Apify API with the RSS feed URL
  3. Parse the resulting JSON in downstream Zaps

Programmatic Pipeline (Node.js)

const{ ApifyClient }=require('apify-client');
const client =newApifyClient({token:'YOUR_API_TOKEN'});
const run =await client.actor('automation-lab/xml-json-converter').call({
inputs:[
{inputUrl:'https://example.com/feed.xml',mode:'auto'},
{inputData:'{"key": "value"}',mode:'jsonToXml',rootElement:'data'}
]
});
const{ items }=await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map(item=> item.output));

API Usage

Node.js

const{ ApifyClient }=require('apify-client');
const client =newApifyClient({token:'YOUR_API_TOKEN'});
const run =await client.actor('automation-lab/xml-json-converter').call({
inputs:[
{
inputData:'<note><to>Tove</to><from>Jani</from><body>Hello!</body></note>',
mode:'xmlToJson',
parseAttributes:true,
prettyPrint:true
}
]
});
const{ items }=await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].output);

Python

from apify_client import ApifyClient
client = ApifyClient('YOUR_API_TOKEN')
run = client.actor('automation-lab/xml-json-converter').call(run_input={
'inputs':[
{
'inputData':'<note><to>Tove</to><from>Jani</from><body>Hello!</body></note>',
'mode':'xmlToJson',
'parseAttributes':True,
'prettyPrint':True,
}
]
})
items = client.dataset(run['defaultDatasetId']).list_items().items
print(items[0]['output'])

cURL

curl-X POST \
"https://api.apify.com/v2/acts/automation-lab~xml-json-converter/runs?token=YOUR_API_TOKEN"\
-H"Content-Type: application/json"\
-d'{
"inputs": [
{
"inputData": "<note><to>Tove</to><from>Jani</from><body>Hello!</body></note>",
"mode": "xmlToJson"
}
]
}'

Use With Claude AI (MCP)

You can use this actor directly inside Claude Code, Claude Desktop, Cursor, or VS Code via the Apify MCP server.

Claude Code

$claude mcp add--transport http apify "https://mcp.apify.com?tools=automation-lab/xml-json-converter"

Claude Desktop / Cursor / VS Code

Add to your MCP config (claude_desktop_config.json or .cursor/mcp.json):

{
"mcpServers":{
"apify":{
"type":"http",
"url":"https://mcp.apify.com?tools=automation-lab/xml-json-converter",
"headers":{
"Authorization":"Bearer YOUR_APIFY_API_TOKEN"
}
}
}
}

Example Prompts

Once connected, you can ask Claude:

  • "Convert this XML to JSON: <book><title>Dune</title><author>Frank Herbert</author></book>"
  • "Fetch the RSS feed at https://example.com/feed.xml and convert it to JSON"
  • "Turn this JSON array into an XML file with root element 'products' and item node 'product'"
  • "I have 3 XML files to convert β€” process them all in one bulk run"

Legality

This actor converts data between formats. It does not scrape, crawl, or access any protected website. All data processing happens on the input you provide. Using this actor does not involve bypassing any access controls or terms of service.


Frequently Asked Questions

What XML features are supported?

The actor supports all standard XML including: element attributes, CDATA sections, nested elements, text nodes, repeated elements (arrays), XML namespaces (treated as attributes), and XML with or without an XML declaration (<?xml version="1.0"?>).

Are XML namespaces supported?

Namespace prefixes (e.g., <ns:element>) are treated as part of the element name. Namespace declarations (xmlns:ns="...") are captured as attributes when parseAttributes is enabled.

What happens if I provide invalid XML or JSON?

The actor catches the error gracefully and records it in the error field of the output item. Other tasks in a bulk run continue processing normally β€” one bad input doesn't stop the rest.

Can I convert very large XML files?

Yes β€” the actor runs in the Apify cloud with up to 256 MB RAM. For extremely large files (multi-MB XML), the conversion still completes efficiently because fast-xml-parser is a streaming-capable parser. If you hit memory limits, contact support.

Why are my repeated XML elements not becoming an array?

fast-xml-parser automatically converts repeated sibling elements with the same tag name into an array. If you see a single element not wrapped in an array, it's because there was only one occurrence of that tag in the input. This is correct behavior β€” a <book> tag that appears once is an object, not a single-element array.

Can I fetch XML from a URL that requires authentication?

Not currently. inputUrl supports public URLs only. For authenticated sources, fetch the XML yourself and pass it via inputData.

What's the difference between rootElement and arrayNodeName?

  • rootElement (default: root) is the outer wrapper element that always wraps the entire JSON output when converting to XML
  • arrayNodeName (default: item) is used when the JSON root is an array β€” each array element gets wrapped in an element with this name

Related Actors

Looking for other format converters or data transformation tools?

You might also like

XML to JSON Converter

eloquent_mountain/xml-to-json-converter

XML to JSON Converter Convert any XML file to JSON effortlessly with this Apify actor. Handle complex XML structures and transform them into structured JSON data. Supports input via URL or direct text paste, making it easy to integrate into your data processing workflows.

Data Converter β€” JSON, CSV & XML

accurate_pouch/data-converter

Convert between JSON, CSV, and XML formats in bulk. JSON to CSV, CSV to JSON, JSON to XML, XML to JSON. Handles quoted fields, nested objects. $0.003/conversion.

πŸ‘ User avatar

Manchitt Sanan

2

Data Format Converter - CSV, JSON, XML Transformation

ntriqpro/data-format-converter

Convert data between common formats: CSV, JSON, and XML. Bulk transform files without manual work.

RSS / XML Scraper

jupri/rss-xml-scraper

πŸ’« Scrape RSS / XML / Sitemap or other XML

JSON To XML Converter

zsoftware/json-to-xml-converter

Easily convert structured JSON data into well-formed XML. This actor accepts raw JSON text or a file and outputs clean, standards-compliant XMLβ€”perfect for data transformation pipelines, integrations, or legacy system compatibility.

Rss To Json Extractor

simplifysme/rss-to-json-extractor

πŸ“° Convert RSS and Atom feeds into structured JSON format for easy integration with your applications. Fast, reliable, and production-ready.

πŸ‘ User avatar

SimplifySME Toolbox

2

XML to JSON Converter

rainminer/xml-to-json-converter

Parse XML documents to structured JSON. Accepts a URL or raw XML string. Automatically unwraps repeated elements into individual dataset rows. Built for AI agents and data pipelines.

RSS to JSON

phazonoverload/rss-to-json

Converts RSS/Atom feeds to clean JSON output, preserving all feed metadata and item attributes.

RSS / XML Scraper

shahidirfan/RSS-XML-Scraper

Meet the RSS / XML Scraper: the most advanced actor for parsing any RSS feed or XML file. It effortlessly extracts clean, structured data from even the most complex sources. Your ultimate tool for content aggregation, data monitoring, and content analysis.

99

5.0

Related articles

How to parse XML in JavaScript (step-by-step guide)
Read more