inyourbrowser.com

XML formatter

XML formatter is a developer tool that formats, minifies, and validates XML documents. It uses the browser's native DOMParser and XMLSerializer, handles SOAP envelopes, RSS feeds, SVG, and config files, and surfaces parser errors with location detail. The tool runs in your browser.

Input XML
Formatted XML

ACTION

Runs entirely in your browser

How to format XML

  1. Paste the XML document into the input pane.
  2. Choose an action: Format for readable output, Minify for compact output, or Validate to check syntax.
  3. Review the result in the output pane.
  4. Click Copy to put the result on the clipboard.

Common uses

  • Reformatting a one-line SOAP response so each element sits on its own line
  • Pretty-printing SVG files before checking them into version control
  • Minifying RSS or Atom feeds to shrink transport size
  • Escaping &, < and > in text before it goes into an element, with the HTML entity encoder
  • Checking the YAML version of the same settings with the YAML validator

Technical specification

  • Algorithm or formula: The input is parsed with native DOMParser, then walked node-by-node. A custom indenter re-emits the tree with consistent indentation, preserving the DOCTYPE, CDATA sections, comments, and processing instructions. Elements that contain text keep their content as written. Minify mode removes the whitespace between elements.
  • Browser API or library: Native DOMParser and XMLSerializer APIs; no external library. The parsed document is copied into plain node data, which the formatter walks recursively; the document itself never enters the page.
  • Input limits: No hard cap; tested with documents up to 5 MB. Parser errors halt formatting and report the line of the issue.
  • Output: Pretty-printed or minified XML, copyable to clipboard. Validate mode returns success or the first parse error when you run it.
  • Known limitations: The tool cannot repair malformed XML; the document must be well-formed before formatting. DTD validation is not performed. Entities declared inside the DOCTYPE are written out as their expanded text. An element named parsererror in the XHTML namespace is reported as a parse error, because browsers use that element to report one.

Frequently asked questions

Which XML documents does this formatter support?
Any well-formed XML document, including SOAP envelopes, RSS or Atom feeds, SVG, Maven POMs, Spring or Tomcat configurations, and custom application XML files. CDATA blocks, comments, and processing instructions are preserved. All formatting runs in your browser using the native DOMParser and XMLSerializer APIs.
Is my XML data sent to a server?
All processing runs in your browser using the native DOMParser and XMLSerializer APIs. Our servers are not involved at any point.
Does the formatter keep the XML declaration and DOCTYPE?
Yes. The <?xml ...?> declaration and the DOCTYPE, including an internal subset in square brackets, are copied from the input as written. Entities declared in that subset are written out as their expanded text in the output.
Can the tool fix malformed XML?
The tool surfaces parser errors with location details. Malformed documents must be repaired before they can be formatted or minified.
What is the difference between formatting and minifying?
Formatting adds indentation and line breaks for readability. Minifying removes inter-element whitespace to make the document as compact as possible for transport or storage.
Are CDATA blocks and comments preserved?
Yes. The walker emits CDATA sections, comments, and processing instructions alongside elements so the structure of the original document is maintained.

Related tools

YAML formatter
Format, validate, and convert YAML. Compatible with Kubernetes, CI configs, and OpenAPI files.
JSON formatter
Pretty-print, minify, validate, and sort JSON keys. Instant output.
HTML entity encoder
Encode special characters to HTML entities and decode them back. Instant, in your browser.
CSV ↔ JSON
Convert CSV to JSON and JSON back to CSV. Handles quoted fields and downloads.

Reviewed and tested September 30, 2026.