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
| Field | Type | Required | Description |
|---|---|---|---|
mode | "beautify" | "minify" | "validate" | required | Beautify with indentation, minify to a single line, or validate only. |
input | string | required | The XML document to format, minify, or validate. |
indent | "2" | "4" | "tab" | required | Indentation used when beautifying: 2 spaces, 4 spaces, or tabs. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
output | string | required | The formatted XML, or the original input in validate mode. Empty when invalid. |
valid | boolean | required | Whether the input is well-formed XML. |
error | unknown | required | Error message when the document is not well-formed. |
errorLine | unknown | required | 1-based line of the error when invalid. |
errorColumn | unknown | required | 1-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.