Skip to main content
NeatUtility

XML Formatter

XML & Markup100% Client-Side
Ready
XML
0 lines0 chars
0 B / 4.77 MB
About this tool, examples & FAQ

Format or minify well-formed XML entirely in your browser, with indentation and comment controls. The tool checks well-formedness — not XSD or DTD validity — and preserves tag values exactly, including leading zeros and text spacing.

Key facts

Verified capabilities and limits of this utility
Accepted inputWell-formed XML text; DOCTYPE and ENTITY declarations are rejected
OperationsFormat with 2-space, 4-space, or tab indentation, or minify; self-closing tags and comment preservation are configurable
Max input size5 MB
Execution deadline3 s
Processing locationBrowser-only: pasted input is not uploaded

How to use

  1. Paste your raw XML markup into the input editor pane.
  2. Select the Format or Minify operation.
  3. Choose indentation (2 spaces, 4 spaces, or Tab) and set self-closing tags and comment preservation.
  4. Click 'Run' to process the XML.
  5. Use 'Copy' or 'Download' to export the formatted or minified result.

Examples

Format a simple element tree

Input

<root><item>one</item><item>two</item></root>

Example output


<root>
  <item>one</item>
  <item>two</item>
</root>

Preserve leading zeros and text spaces

Input

<root><code>00123</code><text>  hello  </text></root>

Example output


<root>
  <code>00123</code>
  <text>  hello  </text>
</root>

Edge cases

Leading zeros and text spacing

Tag and attribute values are never coerced: leading zeros such as 00123 and spaces inside text are preserved exactly in both format and minify modes.

Minify scope

Minify strips only inter-element whitespace-only nodes; significant text content is left untouched.

DOCTYPE and ENTITY declarations

DOCTYPE and ENTITY declarations are rejected for security reasons. Literal occurrences inside CDATA sections or comments are not treated as declarations.

Malformed XML

Documents that fail well-formedness validation are rejected with the parser message and, when available, the line and column where validation stopped.

How it works

  1. Rejects empty or whitespace-only input.
  2. Rejects DOCTYPE and ENTITY declarations before parsing.
  3. Validates well-formedness and reports the parser message with line and column when available.
  4. Parses with tag and attribute values left uncoerced so text whitespace and leading zeros survive.
  5. Builds indented output for format or whitespace-stripped output for minify inside a Web Worker bounded by the tool deadline.

Frequently asked questions

Does this tool validate against an XSD or DTD schema?

No. The tool checks that XML is well-formed and reports where parsing stops; it does not validate against an XSD or DTD schema.

Does formatting change my text content?

No. Values are never coerced: leading zeros, text spacing, and attribute values are preserved exactly. Formatting rewrites structural whitespace and indentation, may convert empty elements to or from self-closing form per that option, and drops comments only when comment preservation is off.

Are comments and CDATA preserved?

Comments are preserved unless you disable comment preservation. In tested cases CDATA sections, namespaces, attributes, and element order are carried through formatting and minification; XML declarations and mixed-content edge cases are not guaranteed.

Why does my XML fail to format?

Formatting fails when the document is not well-formed — for example unclosed tags or mismatched elements. The error message includes the parser reason and, when available, the line and column.

Why are DOCTYPE and ENTITY declarations rejected?

External entity resolution would allow XXE-style attacks, so declarations are rejected before parsing. Only literal text inside CDATA or comments is exempt from that check.

Are there size limits?

Inputs are bounded by the documented input size and execution runs under the tool deadline; very large documents may exceed either boundary.

References