XML Tools

XML Formatter

Make compact or uneven XML easier to read with two-space, four-space, or tab indentation. The formatter keeps element order and avoids adding whitespace inside mixed text content.

✓ Every tool runs in your browser. We do not upload your input or output.

XML Formatter
Keyboard shortcuts

Ctrl/⌘ + Enter: process

Ctrl/⌘ + Shift + F: full screen

Esc: exit full screen

Ctrl/⌘ + F in editor: search

Formatted XML
ReadyLines: 1 · Characters: 0 · Size: 0 KB · Time: — · Cursor: 1:1

How to use

  1. Paste or upload a well-formed XML document, or load the sample.
  2. Choose two spaces, four spaces, or tabs for nested elements.
  3. Review the formatted output; if parsing fails, select the error to move to its line and column.
  4. Copy the complete output or download it as an .xml file.

Examples

Indent an order

Child elements move onto separate lines while their text stays within each tag.

Input
<order id="A-101"><customer>Avery</customer><total>24.50</total></order>
Output
<order id="A-101">
  <customer>Avery</customer>
  <total>24.50</total>
</order>

Keep mixed content together

Inserting indentation into this sentence would add text whitespace, so the formatter leaves it inline.

Input
<p>Hello <strong>world</strong>!</p>
Output
<p>Hello <strong>world</strong>!</p>

Tidy markup for review

XML often arrives as one long line from an API, export, or build step. Formatting creates visual boundaries between parent and child elements, making it easier to spot misplaced tags or compare two documents. Choose an indentation style before copying the result into a repository or ticket. The output remains a complete document, including its XML declaration, comments, CDATA, attributes, and processing instructions where present.

Whitespace matters in XML. A paragraph such as Hello <strong>world</strong>! contains text around an element. Adding line breaks there could change the text a reader sees. This formatter leaves mixed content inline. It also respects xml:space="preserve". For elements that contain only child elements and indentation whitespace, it replaces that indentation with the selected style.

What to check after formatting

Review any document where whitespace is used as data, especially publishing or document formats. Formatting is meant to improve readability, not to infer an application schema. It validates well-formedness first, so malformed tags or attributes produce a clear line and column instead of a misleading partial result.

The work runs in your browser. Large files are processed in a Web Worker, while the input and output panels scroll independently. If a document exceeds 1 MB, press Process or Ctrl/Command + Enter after editing. Copy and Download always use the full output, even if the on-screen preview is shortened for responsiveness.

Frequently asked questions

Does formatting change XML values?

It can normalize indentation-only whitespace between elements. Text mixed with child elements and xml:space=preserve content stay inline to avoid adding text.

Can it fix broken XML?

No. It reports a syntax error with a location. Fix the source before formatting.

Are attributes or elements sorted?

No. The original order is kept. XML element order can carry meaning, and the tool does not reorder it.

Which indentation should I choose?

Use the style expected by your repository. Two spaces is compact, four spaces is more open, and tabs follow tab-based conventions.

Does it fetch a DTD?

No. DOCTYPE declarations are not supported. The formatter never requests external resources.

Related tools