XML

XML Formatter

Serialize XML 1.0 with preserved text, namespaces and optional layout changes

JSON & Data
πŸ”’ 100% client-side β€” your data never leaves this page
Maintained by Evanβ€’Updated: September 30, 2026

Process XML 1.0 locally, with namespaces, comments, CDATA and processing instructions. DTD and entity declarations are unsupported. Input stays in this page; drafts are not stored. Limits: 1 MiB input, 4 MiB output, 20,000 XML nodes including attributes, 64 element levels. Textareas normalize pasted line endings; upload UTF-8 to retain original CSV carriage returns.

XML 1.0

Preserve mode retains parsed text and attribute values. The other modes add/remove whitespace only in element-only parents, and respect xml:space. XML parsing normalizes literal line endings and attribute whitespace. This is not canonicalization or signature verification.

Page reading mode

The full guide also includes pitfalls, worked examples, snippets, FAQs, and related tools for checking results or troubleshooting.

About this tool

XML Formatter parses one well-formed XML 1.0 document and writes escaped XML while retaining element names, namespaces, comments, processing instructions and CDATA. Preserve mode retains parsed text and attribute values, including carriage returns represented by character references. Indent mode uses two spaces and changes only layout whitespace in parents containing elements without non-whitespace text or CDATA; compact mode removes that same layout whitespace. Both respect inherited xml:space="preserve". XML parsing itself normalizes literal line endings and attribute whitespace, and serialization may change quotes, declarations and empty-element syntax. This tool checks syntax, not XSD validity, canonicalization, byte identity or signatures. DTD and entity declarations are rejected. Input is limited to 1 MiB, output to 4 MiB, XML to 20,000 nodes including attributes and 64 element levels. UTF-8 uploads use strict decoding; pasted text follows the browser textarea line-ending rules. Processing runs locally, and draft input is not saved.

Scenario Recipes

01

Check a payload without losing mixed text

Goal: Inspect parsed values before choosing an optional layout change.

  1. Paste XML or upload UTF-8. Begin with Preserve parsed whitespace; DTD declarations require a different parser.
  2. Compare text, attribute values, CDATA and namespace bindings. Use indentation or compaction only when element-only layout whitespace is irrelevant.
  3. Download the complete XML. Validate any business schema or signature in the receiving system using its own rules.

Result: Escaped XML with a clearly chosen whitespace policy.

Failure Clinic (Common Pitfalls)

A formatter changed text between sibling elements

Cause: Whitespace-only text can still be significant to an XML consumer.

Fix: Choose Preserve parsed whitespace. Do not use compact mode merely because a space looks like visual indentation.

A document includes a DOCTYPE or needs XSD validation

Cause: This bounded browser tool supports a no-DTD XML 1.0 subset and checks syntax only.

Fix: Use a dedicated parser and explicit schema/entity rules for that workflow; do not remove declarations without checking their meaning.

Production Snippets

Mixed text and CDATA are values, not indentation

xml

<root>
  <p>Hello <b>world</b> !</p>
  <raw><![CDATA[a < b & c]]></raw>
  <value a="&#9;&#10;&#13;">a&#13;b</value>
</root>

Frequently Asked Questions

Which mode should I choose for mixed content?

Start with Preserve parsed whitespace. Mixed text such as Hello <b>world</b> !, leaf spaces and CDATA remain intact. Indent and compact intentionally change whitespace in eligible element-only parents; use them only when those layout nodes are unimportant to your consumer.

Does formatting preserve the original bytes or digital signature?

No. XML parsing normalizes some source characters, and serialization may change quote styles, empty tags and the declaration. This is not C14N or signature verification. Keep the original document for signed workflows.

Are namespaces and entities supported?

Namespace declarations, prefixes, predefined entities and numeric character references are supported. DTD and custom entity declarations are rejected; external resources and schemas are not loaded.

Is the input saved or uploaded?

Input is limited to 1 MiB, output to 4 MiB, XML to 20,000 nodes including attributes and 64 element levels. UTF-8 uploads use strict decoding; pasted text follows the browser textarea line-ending rules. Processing runs locally, and draft input is not saved.

Keep browsing