XML formatter

Pretty-print XML with consistent indentation, or collapse it to a single line.

Input

The XML to format.
Spaces per level. 0 removes whitespace between tags.

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/xml-format \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"<a><b>1</b><c x=\"2\"/></a>"}}'
import json, urllib.request

body = {'input': {'text': '<a><b>1</b><c x="2"/></a>'}}
request = urllib.request.Request("https://setget.net/v1/tools/xml-format", 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/xml-format", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"<a><b>1</b><c x=\"2\"/></a>"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "xml-format",
  "input": {
    "text": "<a><b>1</b><c x=\"2\"/></a>"
  }
}
{
  "input": {
    "text": "<a><b>1</b><c x=\"2\"/></a>"
  }
}

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

Inputs

NameTypeRequiredWhat it does
text string yes The XML to format.
indent integer no Spaces per level. 0 removes whitespace between tags. Default: 2. From 0 to 8.

Example

Input
{
  "text": "<a><b>1</b><c x=\"2\"/></a>"
}
Result
{
  "text": "<a>\n  <b>1</b>\n  <c x=\"2\" />\n</a>"
}