XML Formatter API

Format, beautify, minify, and validate XML online. Proper indentation, clear error detection with line numbers. 100% client-side — no uploads.

The XML Formatter is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/xml-formatter — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.

Request body

FieldTypeRequiredDescription
mode"beautify" | "minify" | "validate"requiredBeautify with indentation, minify to a single line, or validate only.
inputstringrequiredThe XML document to format, minify, or validate.
indent"2" | "4" | "tab"requiredIndentation used when beautifying: 2 spaces, 4 spaces, or tabs.

Response

FieldTypeRequiredDescription
outputstringrequiredThe formatted XML, or the original input in validate mode. Empty when invalid.
validbooleanrequiredWhether the input is well-formed XML.
errorunknownrequiredError message when the document is not well-formed.
errorLineunknownrequired1-based line of the error when invalid.
errorColumnunknownrequired1-based column of the error when invalid.

Example request

curl -X POST https://dot.tools/api/tools/xml-formatter \
  -H 'Content-Type: application/json' \
  -d '{
  "mode": "beautify",
  "indent": "2",
  "input": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><catalog><tool id=\"xml-formatter\" category=\"format\"><name>XML Formatter</name><clientSide>true</clientSide></tool><tool id=\"json-formatter\" category=\"format\"><name>JSON Formatter</name></tool></catalog>"
}'

Sample response

{
  "ok": true,
  "result": {
    "output": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<catalog>\n  <tool id=\"xml-formatter\" category=\"format\">\n    <name>XML Formatter</name>\n    <clientSide>true</clientSide>\n  </tool>\n  <tool id=\"json-formatter\" category=\"format\">\n    <name>JSON Formatter</name>\n  </tool>\n</catalog>",
    "valid": true,
    "error": null,
    "errorLine": null,
    "errorColumn": null
  }
}

Use the free XML Formatter in your browser, read the XML Formatter guide, or import the full OpenAPI specification.