XML tools

XML formatterInspect structure without trimming text

Automatic mode updates after 350ms. Turn it off to run manually with Ctrl/Cmd+Enter. Text-containing subtrees keep their original layout.

XML formatter

XML input

Result

Your XML is processed in this browser tab without uploading it.

Options

Subtrees containing text, including whitespace, CDATA or xml:space="preserve" stay unchanged. Existing indentation may remain unchanged too.

Input or options changed. The result needs updating.

A dense SOAP response can hide the element that explains a failed request. This XML formatter opens up containers that have no direct text and gives you a separate structure view for the rest. It works as an XML beautifier without treating every space between tags as disposable.

For XML pretty print, choose two or four spaces. The XML minifier uses a conservative compact mode: existing text, including indentation whitespace, remains protected. A document that already has indentation may therefore keep the same size.

What the XML formatter helps you inspect

Keep a word separator a word separator

In a paragraph containing child tags, the space between two elements can separate words. Removing it changes the text that a reader receives. Any element with direct text, even pure whitespace, or CDATA keeps its entire source subtree. A layout change is limited to containers without direct text, so preserving content can mean preserving existing indentation.

A structural branch opens into indented levels while a mixed text branch keeps its original spacing.

Trace a namespace declaration to its element

A SOAP envelope can declare a prefix on one element and redeclare it farther down. Inspect declaration entries beside the tree to see the prefix, URI, owning element and source line. The listing shows declarations, including repeated ones; it is not a list of remote resources to fetch.

Colored namespace declarations correspond to their owning nodes in an XML tree.

Three checks before taking the result

01

Choose when the result refreshes

With automatic mode on, input and format options settle for 350ms before processing. Disable it for explicit runs with the button or Ctrl/Cmd+Enter. Exports remain disabled while a previous result is out of date.

02

Read the protection count

If switching from two to four spaces seems to do nothing, check the protected subtree count. Whitespace already inside the root is text too. The formatter preserves that root rather than guessing whether its indentation is meaningful.

03

Review replacements before applying

Loading a different example or clearing existing input opens a replacement preview with character counts. Apply makes the change; cancel keeps the current work. Undo restores the preceding input and result together.

Inspect syntax, hierarchy and declarations

XML 1.0 syntax positions

The XML formatter checks matching tags, legal characters, quoted attributes and namespace constraints before returning a result. An error includes its source line and column so you can correct the input instead of inspecting partially repaired output.

A navigable XML tree view

Expand and collapse branches to follow nesting in a long configuration or feed. Lists initially show 50 entries, with 50 more per action; export includes the full result. Click an element or namespace entry to reveal its source line. Switching views does not edit the XML.

Declaration context

Namespace entries connect each xmlns declaration to its element and line. A default namespace is labeled separately from named prefixes. Declarations remain in their original order and are never renamed to make the tree appear simpler.

A current, downloadable result

Copy or download only after the current input and options have completed successfully. Downloads contain UTF-8 XML. A syntax error or an input edit makes the earlier result unavailable for export until it is refreshed.

The limits behind the result

Text wins over reindentation
Direct text includes spaces, line breaks and character references. An element containing any of these, CDATA, or xml:space="preserve" protects its whole subtree. Compact mode does not delete inter-element text; it can only simplify unprotected tag layout and whitespace outside the root. This is not canonical XML or a guarantee that digital signatures remain valid.
One supported document form
Use one well-formed XML 1.0 document. Every DOCTYPE is rejected, and no external entity or namespace resource is fetched. An encoding declaration must be UTF-8 or UTF8, or be absent; other declarations are rejected because the download uses UTF-8 bytes.
Syntax is not schema validation
No XSD, DTD or RELAX NG schema is evaluated. The structure view cannot certify an invoice, SOAP contract or application-specific field requirement. XPath, XSLT, automatic repair and conversion to JSON are outside this tool.
Bounded pasted input
Input allows 500,000 UTF-16 code units, 20,000 nodes and depth 100. Output is capped at 2,000,000 code units. A supplementary character can occupy two code units. Paste text directly; there is no file import or URL loading. Either input or output exceeding a limit stops processing without a partial export.

XML formatter questions

How do formatting and minifying differ?

Pretty mode adds layout to containers without direct text. Compact mode trims only unprotected tag layout and document-level whitespace. Both protect all text-bearing subtrees, so compact mode may leave a previously indented document unchanged.

Can formatting alter text or CDATA?

The XML formatter preserves the raw subtree whenever an element directly contains text or CDATA. This includes whitespace-only text. Attributes, comments and namespace spellings are not rewritten to force a different layout.

Is my XML uploaded to a server?

Processing happens in the current browser tab. Copy and download are explicit export actions; namespace URIs do not trigger resource requests.

How can I fix invalid XML?

Use the reported line and column to inspect unmatched tags, missing attribute quotes, bare ampersands or undeclared prefixes. Correct the input and rerun. The tool does not guess missing markup or silently repair a document.

Can I inspect XML as a tree?

Yes. Select Structure and expand the branches you need. The namespace view adds declaration locations. Neither view edits the document or evaluates XPath expressions.

Found an unexpected result?

Try the XML formatter on a response

Use the XML formatter example to compare an expandable container with protected text, then inspect where its namespace prefixes are declared.