XML Format Validate Query Pretty Print XPath XSD Diff API
Free tier included · ToolsIt pretty-prints XML while keeping comments, processing instructions, CDATA and namespace prefixes; validates well-formedness with element/attribute/depth/namespace stats and full W3C XML Schema (XSD) validation with line/column errors; runs full XPath 1.0 (lxml) including axes, predicates, functions and unions; and adds convert (XML↔JSON/CSV/canonical), diff, minify, fix (attribute sorting + C14N canonicalization) and extended stats.
The core safety guarantee is the XXE guard: every endpoint rejects any document containing a DOCTYPE or ENTITY declaration with `doctype_not_allowed` (422), and the underlying lxml parser never resolves entities, loads DTDs or touches the network (`resolve_entities=False, load_dtd=False, no_network=True`). This removes the classic SSRF/DoS vector from pipelines that consume third-party XML — feeds, invoices, configs, LLM tooling.
Who needs it: integration engineers validating supplier XML before ingestion; ETL pipelines that must reformat, query and diff documents without hosting a parser; developers adding XSD validation to sign-up or upload flows; auditors comparing config snapshots.
Honest limits: documents are capped at 1,048,576 bytes on `/format`, `/validate`, `/query` and `/stats`; `/convert`, `/minify`, `/fix` and `/diff` accept the same cap. XPath runs in a killable worker process with a 3-second default time limit (`XMLSVC_QUERY_SEC`), so pathological expressions like `//*[count(//*) > 0]` on large documents are bounded. `/query` returns at most 10,000 matches (`XMLSVC_MAX_MATCHES`). XSD validation uses the schema you supply. The service is offline and stateless — no logs, no databases, no cross-request state.
Endpoints
| Method | Path | What it does |
|---|---|---|
GET | / | API metadata: name, version, and paths to the interactive docs and health endpoint. |
GET | /health | Liveness probe; returns status "ok" while the process is up. |
POST | /format | Pretty-print XML with configurable indentation (0–8 spaces). Comments, processing instructions, CDATA and namespace prefixes are preserved; mixed content is never re-indented. DOCTYPE/ENTITY rejected with 422. |
POST | /validate | Validate XML well-formedness: returns a summary with root element, element/attribute counts, max depth, namespaces, and a reason for malformed documents. DOCTYPE/ENTITY rejected with 422. |
POST | /query | Query XML with full XPath 1.0 (lxml). Node-sets are returned as matches in document order; number/string/boolean expressions as result. Supports namespaces via the namespaces map. DOCTYPE/ENTITY rejected with 422. |
POST | /minify | Remove all unnecessary whitespace from XML while preserving structure, comments, and CDATA sections. |
POST | /convert | Convert XML to JSON, CSV, or canonical XML format. |
POST | /diff | Compare two XML documents and return a list of structural differences. |
POST | /fix | Auto-fix XML by sorting attributes alphabetically and applying C14N canonicalization. |
POST | /stats | Compute detailed statistics about an XML document including node counts, depth, namespaces, and element/attribute type distributions. |
POST | /validate/schema | Validate an XML document against a W3C XML Schema (XSD). Returns validity status and any schema validation errors with line/column information. |
Quick start
curl -X POST "https://xmltool.p.rapidapi.com/format" \
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
-H "X-RapidAPI-Host: xmltool.p.rapidapi.com" \
-H "Content-Type: application/json" \
-d '{"xml":"<root><!-- keep --><item id=\"1\">first</item><item id=\"2\">second</item></root>","indent":2}'
FAQ
Does the API resolve external entities or load DTDs?
No. The underlying lxml parser uses `resolve_entities=False, load_dtd=False, no_network=True`, and every endpoint rejects any document containing a DOCTYPE or ENTITY declaration with `doctype_not_allowed` (422).
What XPath features are supported?
Full XPath 1.0 via lxml/libxml2: axes, predicates, functions, unions, namespaces. Node-sets are returned as matches in document order; number/string/boolean expressions as `result`. A 3-second default time limit (`XMLSVC_QUERY_SEC`) bounds pathological expressions.
How large a document can I send?
Up to 1,048,576 bytes (1 MB) on all endpoints. `/query` returns at most 10,000 matches (`XMLSVC_MAX_MATCHES`).
Is the service offline and stateless?
Yes. No external network calls, no databases, no request logs, no cross-request state. Validation, formatting and querying run entirely on the embedded lxml parser.
Try XML Format Validate Query Pretty Print XPath XSD Diff free
Free tier on every plan. Get an API key and start calling in under a minute.
Open on RapidAPI