Help
  • Keep comments: preserve comment content when formatting the XML
  • Unescape: convert escaped characters back to their original form when formatting

XML Formatter

This free online XML formatter turns messy markup into clean, readable code — and can minify or escape it in one click.

All tools on this site run entirely in your browser locally. No data is uploaded to any server.

Features:

  • Beautify: Re-indent XML with a 2, 3 or 4 spaces indent (2 by default) and a clear tag hierarchy
  • Minify: Strip whitespace and line breaks, compressing everything into a single line
  • Escape / Unescape: Escape special characters, or restore escaped text back to its original form
  • Keep comments: Preserve comments when formatting
  • Code folding: Collapse and expand nodes to navigate large documents
  • Local files: Open an XML file from your computer, or drag and drop it into the editor

Common uses:

  • Cleaning up unformatted XML for easier reading and debugging
  • Compressing XML to reduce transfer size
  • Spotting broken tag nesting and other structural issues
  • Escaping XML snippets for safe embedding in strings or configs

FAQ:

  • Q: The left pane formats as I type. What are the Format XML and Minify buttons for?
    A: Every edit on the left is re-indented automatically and written to the right pane using the indent width chosen in the toolbar (2 spaces by default). Format XML re-indents the text already in the right pane, while Minify strips line breaks and extra whitespace to put it on a single line. Both work on the right pane only and leave your original on the left untouched. If the right-hand text has syntax errors, either button stops and shows "XML format error".
  • Q: Does Escape convert angle brackets and ampersands into XML entities?
    A: No. Escape only doubles backslashes and puts a backslash before each double quote, which is handy when you want to embed a whole XML snippet in a code string. Angle brackets, ampersands and entities such as < are left exactly as they are. Neither Escape nor Unescape deals with XML entities.
  • Q: What do Keep comments, Unescape, Indent and Wrap long lines change?
    A: Keep comments is on by default; turn it off and both formatting and minifying drop comments, and formatting also tidies the whitespace before xmlns. Unescape is off by default — with it on, each automatic format pass reverses the backslash and quote escaping done by Escape. The Indent dropdown in the toolbar picks 2, 3 or 4 spaces (2 by default), while "Wrap long lines" in Settings only changes how long lines are displayed in the right pane, not the text or the formatting. All of these settings are saved in your browser and restored on your next visit.
  • Q: What is the default indent, and can I change it?
    A: Both automatic formatting and the Format XML button use the indent width chosen in the toolbar: 2 spaces by default, with 3 and 4 also available. Changing the dropdown re-formats the text immediately if the left pane isn't empty, so there's no need to click Format XML again, and your choice is remembered. Tab indents text you edit by hand but won't affect the next formatting pass; to adjust a single line, edit the right pane directly. You can also drag the divider between the panes to resize them — the left pane can't go below 460px — and that position is saved too.
  • Q: What do the tick and the exclamation mark on the right mean, and can I still save invalid XML?
    A: After each change the right pane is checked for syntax errors: a tick means clean markup, a red exclamation mark means errors, which are also highlighted in the editor. Save opens a confirmation when errors are present so you can save anyway, while Format XML and Minify simply stop with "XML format error". Save downloads an .xml file named after the site, with line endings converted to CRLF.
  • Q: What do Fold All, Search and Fullscreen do on the right pane?
    A: Fold All collapses or expands every node at once; a folded block shows how many child elements it contains. Search opens the find dialog, and with the right editor focused you can use Ctrl-F to find, Ctrl-Enter for the next match, Ctrl-Shift-Enter for the previous one and Ctrl-H to replace. F11 toggles fullscreen and ESC exits. These all act on the right pane only.