Skip to main content
GARGLOO

XML Formatter Online

Readable XML in one keystroke.

Runs on your deviceXML

At a glance

Input:
XML
Processing:
Runs locally in your browser
Privacy:
Nothing you type is sent to a server

Last updated: 2026-11-13

Common use cases

  • Reading a minified API or config response by pretty-printing it
  • Shrinking an XML payload with minify before pasting it into a request
  • Sorting attributes to diff two XML files deterministically
  • Locating a mismatched tag by its exact line and column

About this tool

A fast, private XML formatter with indent control, attribute sorting, minify mode and error messages that point at the exact offending character.

How to use it

  1. Paste XML into the editor.
  2. Click Format (⌘/Ctrl+Enter works too).
  3. Adjust indentation or sort attributes as needed.
  4. Copy the result or download as .xml.

Worked examples

Input: <root><a>1</a><b>2</b></root>

Output: <root> <a>1</a> <b>2</b> </root>

The headline example: pretty-printed at 2-space indent it is exactly 4 lines.

Input: <?xml version="1.0" encoding="UTF-8"?><root><a>1</a><b>2</b></root>

Output: 5 lines — the declaration stays on its own first line, then the 4-line body.

The XML declaration is preserved and printed on its own line.

Input: <a></b>

Output: Error: Closing tag </b> does not match open tag <a> — line 1, column 4.

A mismatched close is reported with the exact line and column.

Practical tips

  • Use Ctrl/⌘+Enter to re-run after each fix — the shortcut keeps hands on the keyboard.
  • Pick Format + sort attributes before diffing two XML files: matching attribute order removes false differences.
  • Set indent to match your project (usually 2) so pasted snippets blend with surrounding code.

Common mistakes

  • Pasting XML with an unquoted attribute value — XML demands quotes, and the error position shows where.
  • Closing a tag with the wrong name — the message names both the open and the close tag so the mismatch is obvious.
  • Minifying before debugging: read the formatted version first, minify only when size matters.

How this compares

Most XML formatters in the field are server-side paste bins that upload your document. This one formats, sorts and minifies locally with indent of 2 or 4 spaces or a tab, and reports the exact line and column of the first error. The tradeoff: no XML-to-JSON conversion and no schema validation — for shape checks, pair it with the JSON validator after converting.

Good to know

  • Well-formedness only — a valid document can still have wrong values, and this page cannot know your schema.
  • Formatting will not fix logic errors — correct syntax with wrong values still passes.
  • The 1,000,000-character cap keeps huge documents responsive; split larger files before pasting.

Frequently asked questions

Does formatting send my XML anywhere?

No. Parsing and printing happen entirely in your browser — safe even for payloads with tokens or internal hostnames you'd rather not leak.

How precise are error messages?

Errors pinpoint line and column, e.g. 'Closing tag </b> does not match open tag <a> at line 1, column 4', derived directly from the parse failure position.

How large can input be?

Up to 1,000,000 characters. Comments, CDATA sections and the XML declaration are preserved when formatting; minify keeps them too and only strips optional whitespace.

What do the three actions do?

Format pretty-prints with your indent (2 spaces, 4 spaces or tab). Format + sort attributes also alphabetizes attributes on every tag. Minify strips all optional whitespace for transport.

Does it convert XML to JSON?

No — this tool formats, minifies and validates XML only. For JSON work, use the JSON formatter; for converting between the two, use the CSV to JSON converter for tabular data.

All developer tools
XML Formatter Online | GARGLOO