JSON to XML

Convert JSON into indented XML. "@name" keys become attributes and arrays repeat the tag.

Input

The JSON to convert.
Root tag name, used when the JSON is not an object with a single key.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/json-to-xml \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"{\"user\":{\"@id\":\"7\",\"name\":\"Sam\",\"tag\":[\"a\",\"b\"]}}"}}'
import json, urllib.request

body = {'input': {'text': '{"user":{"@id":"7","name":"Sam","tag":["a","b"]}}'}}
request = urllib.request.Request("https://setget.net/v1/tools/json-to-xml", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/json-to-xml", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"{\"user\":{\"@id\":\"7\",\"name\":\"Sam\",\"tag\":[\"a\",\"b\"]}}"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "json-to-xml",
  "input": {
    "text": "{\"user\":{\"@id\":\"7\",\"name\":\"Sam\",\"tag\":[\"a\",\"b\"]}}"
  }
}
{
  "input": {
    "text": "{\"user\":{\"@id\":\"7\",\"name\":\"Sam\",\"tag\":[\"a\",\"b\"]}}"
  }
}

Endpoint: POST /v1/tools/json-to-xml. Over MCP: run_tool with slug: "json-to-xml". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
text string yes The JSON to convert.
root string no Root tag name, used when the JSON is not an object with a single key. Default: "root".

Example

Input
{
  "text": "{\"user\":{\"@id\":\"7\",\"name\":\"Sam\",\"tag\":[\"a\",\"b\"]}}"
}
Result
{
  "text": "<user id=\"7\">\n  <name>Sam</name>\n  <tag>a</tag>\n  <tag>b</tag>\n</user>"
}