# JSON to XML & XML to JSON Converter (`hipersoft/json-xml-converter`) Actor

Convert JSON to XML or XML to JSON, both ways, with attributes preserved and pretty-printing. Auto-detects the input format. Paste content, pass a list, or fetch from a URL. Great for APIs, SOAP, RSS, config and legacy integrations. Download the result as a file or inline JSON, CSV or Excel.

- **URL**: https://apify.com/hipersoft/json-xml-converter.md
- **Developed by:** [hiper soft](https://apify.com/hipersoft) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.001 / document converted

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## JSON to XML & XML to JSON Converter

Convert **JSON to XML** and **XML to JSON** in either direction with the **JSON / XML Converter**. Paste your content, pass a whole list, or fetch it from a URL — the converter **auto-detects the format**, preserves **attributes**, and pretty-prints the result. Download each conversion as a ready file or as inline data in **JSON, CSV or Excel**.

Perfect for **API and webhook integrations, SOAP and legacy systems, RSS/Atom feeds, config-file conversion and data-pipeline glue** in n8n, Make and Zapier, it turns one format into the other with zero code.

### What it does

- 🔄 **Both directions** — JSON → XML and XML → JSON.
- 🧭 **Auto-detect** — figures out whether your input is JSON or XML and converts the other way.
- 🏷️ **Keeps attributes** — XML attributes map to JSON keys (and back) using a configurable prefix.
- ✨ **Pretty-print** — clean, indented output that's easy to read and diff.
- 📚 **Batch & URL** — convert one document, a list of documents, or fetch a document from a URL.
- 📎 **File + inline output** — each result is saved as a downloadable file and (when small) included inline in the dataset.
- 📤 **Export anywhere** — JSON, CSV or Excel, or wire the output field into the next step of an automation.

### Example

**XML in**

```xml
<catalog><book id="1"><title>Node</title><price>29.99</price></book></catalog>
```

**JSON out**

```json
{ "catalog": { "book": { "title": "Node", "price": 29.99, "@_id": 1 } } }
```

### How to use it

1. Paste your **content** (or add a list, or a **URL** to fetch).
2. Choose a **direction** — Auto, JSON → XML, or XML → JSON.
3. Optionally set **pretty-print**, a **root element name** (for arrays), and the **attribute prefix**.
4. Run, and download the converted file or read it from the results.

### Input fields

| Field | Description |
|-------|-------------|
| **Content** | The JSON or XML to convert. |
| **Multiple documents** | Optional list of documents to convert in one run. |
| **Fetch from URL** | Optional URL to a JSON/XML document. |
| **Direction** | Auto-detect, JSON → XML, or XML → JSON. |
| **Pretty-print** | Indent the output. |
| **Root element name** | Wrapper name when JSON has no single root (e.g. an array). |
| **Attribute prefix** | JSON keys with this prefix become XML attributes (default `@_`). |

### Output fields

`index`, `ok`, `from`, `to`, `bytesIn`, `bytesOut`, `error`, `fileKey`, `fileUrl`, `output` (inline for small results).

### Popular use cases

- **API integration** — bridge a JSON service to an XML/SOAP endpoint or vice versa.
- **Feed processing** — turn RSS/Atom XML into JSON for downstream steps.
- **Config conversion** — move between JSON and XML configuration formats.
- **Legacy systems** — adapt modern JSON payloads to XML-only backends.
- **Automation glue** — a conversion step inside an n8n, Make or Zapier workflow.

### FAQ

**Do I need an account or key?**
No. Paste your content and run.

**Are XML attributes preserved?**
Yes — attributes convert to JSON keys prefixed with `@_` (configurable) and back to attributes on the return trip.

**Can I convert many documents at once?**
Yes — add a list of documents and each is converted independently, with its own downloadable file.

**Where does the converted file go?**
Each conversion is saved to the run's storage with a direct download link in the results; small results are also included inline.

**Can I export to Excel or Google Sheets?**
Yes — the results table downloads as JSON, CSV or Excel and integrates with Sheets and automation tools.

***

Convert **JSON ↔ XML** both ways — attributes preserved, auto-detected, pretty-printed and export-ready for APIs, feeds and automation.

# Actor input Schema

## `content` (type: `string`):

The JSON or XML to convert. Paste it here. For multiple documents use the list below, or fetch from a URL.

## `contents` (type: `array`):

Optional — a list of JSON/XML documents to convert in one run. Each is converted independently.

## `contentUrl` (type: `string`):

Optional — a URL to a JSON or XML document to fetch and convert.

## `direction` (type: `string`):

Which way to convert. Auto-detects from the input when set to Auto.

## `pretty` (type: `boolean`):

Indent the output for readability.

## `rootName` (type: `string`):

Wrapper element name used when the JSON has no single root (e.g. an array).

## `attributePrefix` (type: `string`):

JSON keys starting with this prefix become XML attributes (and vice versa). Default '@\_'.

## Actor input object example

```json
{
  "contents": [],
  "direction": "auto",
  "pretty": true,
  "rootName": "root",
  "attributePrefix": "@_"
}
```

# Actor output Schema

## `results` (type: `string`):

The results as dataset items.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "content": "",
    "contents": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("hipersoft/json-xml-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "content": "",
    "contents": [],
}

# Run the Actor and wait for it to finish
run = client.actor("hipersoft/json-xml-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "content": "",
  "contents": []
}' |
apify call hipersoft/json-xml-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hipersoft/json-xml-converter"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/9Fo4wVAUyrYfjWHJA/builds/M6jkHZTSDnve0xF9O/openapi.json
