Developer Tools

XML Formatter

Format and validate XML locally with adjustable indentation. Preserve mixed text, CDATA and xml:space subtrees, then copy or download UTF-8 XML without uploading it.

Your content stays on your device Free, with no account
Readable XML, with careful whitespace handling Local XML parser
Up to 100,000 UTF-16 units, 20,000 tokens and 100 nested elements. One root element; no DTDs or entity declarations.

Formatting adds indentation text. Leave this unchecked to preserve existing whitespace-only content. Mixed text, CDATA and xml:space="preserve" subtrees stay unchanged. Use Validate only for whitespace-sensitive or signed XML.

YOUR RESULT

Ready. Paste XML and choose an action.

Checks well-formedness, not XSD/DTD validity or canonical equivalence. Tag and attribute spellings, quotes, entity references, comments and processing instructions are retained. Output is text only, never rendered or executed. Downloads are UTF-8; other declared encodings are rejected.

A FEW SIMPLE STEPS

How to use XML Formatter

  1. Paste a complete XML document with one root element, or select Try an example.
  2. Choose Format or Validate only. For formatting, select spaces or tabs and choose whether to replace whitespace-only text between markup nodes.
  3. Select Process XML. Review the output and any syntax errors; mixed text, CDATA and xml:space="preserve" subtrees stay unchanged.
  4. Copy or download the UTF-8 output. Formatting adds indentation text, so use Validate only for signed or whitespace-sensitive documents.
PRIVATE BY DESIGN

Why use this tool?

XML is checked and formatted on your device with no uploads, accounts or saved input history. Source markup is never inserted into the visible page. DTDs and entity declarations are rejected before parsing, and lexical markup is retained instead of reserialized.

Tool inputs stay in your browser. Only your theme preference is saved on this device.

A few things worth knowing

Does formatting preserve all XML meaning?

No formatter can infer whether whitespace is significant without application context. This tool adds indentation between markup children, and its checked reindent option replaces existing whitespace-only text there. Mixed text and CDATA protect their entire containing subtree; xml:space="preserve" also protects the entire subtree, including nested overrides. Leaf text remains unchanged. Use Validate only for whitespace-sensitive, signed or canonicalized XML.

What is preserved exactly?

After textarea-style CRLF/CR-to-LF normalization, original tag spelling, attribute order and quotes, entity-reference spelling, comments, processing instructions, CDATA and empty-element notation are retained. Protected subtrees are copied verbatim. Formatting only changes whitespace between markup nodes in eligible elements. Uncheck reindent to preserve subtrees that already contain whitespace text; eligible elements with no text can still receive new indentation.

What does Validate only check?

It uses your browser’s XML parser to check well-formedness within the tool’s supported subset and limits. It does not check an XSD, a DTD, application semantics or digital signatures. Error wording depends on the browser; scanner errors include line and UTF-16 column. The browser’s reserved parser-error namespace is treated as an error. Validate only produces no output or download.

Are external entities or stylesheets loaded?

DTDs, entity declarations and other unsupported declarations are rejected by the scanner before parsing. Standard predefined entities and numeric character references are allowed. XML is parsed into a detached document for syntax checking and never rendered or inserted into the page. Processing instructions are retained as text, not followed. This tool does not resolve schemas, stylesheets, XInclude or external resources.

Which encodings and limits are supported?

Paste text already decoded by your browser. Downloads use UTF-8. An encoding declaration must be UTF-8/UTF8 or omitted; other declared encodings are rejected rather than exported under a misleading label. Input is limited to 100,000 UTF-16 units, 20,000 lexical tokens and 100 nested elements; formatted output is limited to 1,000,000 units. Unpaired UTF-16 surrogates are rejected. Input is never truncated.

Why is some XML left on one line?

Text-sensitive subtrees are retained without internal formatting. For example, <p>Hello <em>world</em>!</p> must keep its text spacing. A CDATA section or xml:space="preserve" also protects its containing subtree. With reindent unchecked, even whitespace-only text protects its containing subtree. Output may therefore intentionally mix indented blocks with unchanged inline content.