Developer Tools

XML Formatter

Format, indent, or minify XML markup online with custom spacing.

Run tool

This XML formatting tool organizes raw markup into structured, readable documents or compact strings. When working with API responses, configuration files, or data exports, unformatted XML can be difficult to inspect. The formatter parses your text, validates document structure, and applies consistent indentation across nested elements. You can select standard beautification with custom spacing ranging from zero to eight spaces per level, with two spaces applied by default. If your project requires smaller file sizes or transmission payloads, switch to minify mode. In this mode, the tool strips comments, removes unnecessary whitespace between tags, and trims outer margins while checking that the underlying markup remains well formed. Empty text inputs produce empty output without errors. If your markup contains unclosed tags or invalid syntax, the tool alerts you so you can fix errors before exporting. The utility processes XML documents up to 1,000,000 bytes directly.

Instructions

  1. Paste or type your XML text into the XML Input field.
  2. Set the indent spacing between 0 and 8 spaces, or leave it at 2 for standard formatting.
  3. Choose your formatting style by keeping beautify or entering minify.
  4. Click the run button to generate your formatted XML output.

Examples

  • Beautifying a single-line payload: Input <user><name>Alice</name><role>Admin</role></user> with an indent of 2 produces a formatted tree with indented child elements.
  • Minifying structured XML: Input a multi-line document with comments to strip comment blocks and extra whitespace, producing a continuous single-line string.

FAQ

What happens if my XML has syntax errors?

The tool parses and validates the markup before outputting text. If a tag is unclosed or improperly nested, you will see an error notification instead of formatted text.

What is the maximum file size supported?

The formatter accepts text inputs containing up to 1,000,000 UTF-8 bytes for non-empty markup.

How does minify mode handle XML comments?

Minify mode removes XML comments and strips unnecessary whitespace between tags to create a compact string.

What indentation width is applied by default?

The default indentation is 2 spaces. You can configure any integer between 0 and 8 spaces; values outside this range automatically reset to 2.

Embed this tool

Add this working SmartPlusLab tool to your website with the code below.