XML tools

XML formatterInspect structure without trimming text

Beautify or compact the current document. Compact removes line breaks between tags, while same-line spaces and text stay.

XML formatter

Current document

Pretty and Compact rewrite the current document. Indentation affects only the next pretty run. Structure and namespaces are read-only and follow the current text. A failure keeps that text.

Ctrl/Cmd+Enter: PrettyCtrl/Cmd+Shift+Enter: Compact

Paste XML or load the example.

Options

Compact removes line breaks and indentation between tags. Spaces on the same line, text, character references, CDATA and xml:space="preserve" stay unchanged. Pretty mode does not indent inside existing text.

First input: 500,000 UTF-16 units. Output and later processing of a generated document: 2,000,000. At most 20,000 nodes and depth 100.

View original

Your XML is processed in this browser tab without uploading it. Undo history stays in this tab. Long documents limit how much history is kept.

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 removes line breaks and indentation between tags, so a beautified document can return to one line. Spaces on the same line, text and CDATA stay.

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. Compact mode keeps that same-line space and removes whitespace between tags only when it contains a line break. Pretty mode leaves a subtree unchanged when the element already contains text or CDATA.

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

Format only when you choose

Nothing is beautified or compacted automatically. Click Pretty or Compact, or press Ctrl/Cmd+Enter to prettify and Ctrl/Cmd+Shift+Enter to compact. Indentation affects only the next pretty run. A failure keeps the current document and does not add a successful history step.

02

Read the protection count

If switching from two to four spaces seems to do nothing, pretty mode is leaving an element that already contains text. Use Compact to remove those line breaks. Spaces on the same line stay.

03

The editor holds the full document

Example and Clear start a new document and can be undone. Undo and redo cover edits, pretty and compact runs, restoring the original, examples and clearing. Copy and download export the full current document. Structure and namespaces describe only that document.

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 and download export the full current document, including manual edits that have not been formatted again. Structure and namespaces are read-only and jump to the current line. Downloads use UTF-8. A failure does not rewrite the document.

The limits behind the result

Text wins over reindentation
Pretty mode keeps a whole subtree when it contains direct text, character references, CDATA, or xml:space="preserve". Compact mode removes whitespace between tags when that whitespace contains a line break, and keeps same-line spaces, text and CDATA. A beautified document can return to one line. This is not canonical XML or a digital-signature check.
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
The first input is limited to 500,000 UTF-16 units. Output and further processing of a generated document are limited to 2,000,000. There may be at most 20,000 nodes and depth 100. Some characters use two units. Input is pasted text; there is no file import or URL fetch. Oversized work stops without exporting a partial document.

XML formatter questions

How do formatting and minifying differ?

Pretty mode adds layout to containers without direct text. Compact mode removes line breaks and indentation between tags. Same-line spaces, text, character references and CDATA stay, as do subtrees marked xml:space="preserve".

Can formatting alter text or CDATA?

The XML formatter keeps text and CDATA. Pretty mode does not indent inside them. Compact mode removes only line-break indentation between tags. Attributes, comments and namespace spellings are not rewritten.

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.