Home Tools About Us ♥ Support Us
</> XML Formatter

Format, validate &
explore XML

Beautify, minify, validate, and convert XML to JSON with a live tree view — all instantly, in your browser.

ℹ️ Legacy encodings (ISO-8859-x, windows-125x) are best-effort: browsers only natively support UTF-8, so characters outside the Latin-1 range are replaced with "?" on download. The declaration text itself is always written exactly as selected.

Input XML
Ready
Output
// Output will appear here after formatting
Waiting

🕘 Local History

Saved only on this device (browser local storage) — never uploaded anywhere.

No history yet. Format some XML to see it appear here.

How to use every option

  1. Paste or upload your XML — type/paste into the Input box, drag a file onto it, or use the Upload button. Files up to your browser's available memory are supported.
  2. Validate first — click Validate to check the document is well-formed. Errors show the approximate line/column when the browser reports one.
  3. Pick an indentation level — 2, 3, or 4 spaces, Tab-delimited, or Compact (no indentation, single line).
  4. Choose a trim mode — Normalize collapses whitespace in text nodes to single spaces; Trim removes only leading/trailing whitespace; Trim Whitespace-Only clears text nodes that are pure whitespace while leaving real text untouched; Preserve makes no changes to text; Collapse Blank Lines reduces repeated blank lines to one.
  5. Set attribute quote style — double or single quotes around attribute values.
  6. Set the line ending — LF, CRLF, or CR, useful when targeting Windows vs Unix-based systems.
  7. Pick an encoding declaration — sets theencoding="…" value in the<?xml?> declaration; toggle the declaration on/off entirely with the checkbox.
  8. Toggle extra options — sort attributes alphabetically, strip comments, remove empty elements, or force self-closing tags for empty elements.
  9. Click Format to beautify, orMinify to compact everything onto one line.Fix attempts to auto-repair common issues like unescaped ampersands and smart quotes.
  10. Switch views — Pretty shows formatted text, Tree shows a collapsible element tree, JSON shows an XML→JSON conversion.
  11. Search tags, attributes, or text content using the search bar — matches are counted and highlighted.
  12. Copy or download the result, or revisit a past conversion from Local History.

One tool, every XML task

Built to replace the separate formatter, validator, minifier, and converter tools people usually juggle.

Format & Beautify
Pretty-print with configurable indentation — 2/3/4 spaces, tabs, or compact.
Well-Formedness Validation
Catch mismatched tags and syntax errors with line/column detail where available.
Minify
Strip whitespace for compact payloads in one click.
🌳
Live Tree View
Browse elements, attributes, and text as a collapsible hierarchy.
🔀
XML → JSON
Convert any document into structured JSON, attributes and text included.
🔤
25+ Encoding Declarations
UTF-8/16/32, US-ASCII, ISO-8859-1 through 15, and all windows-125x code pages.
🧹
Comment & Empty-Element Removal
Strip comments or drop elements with no attributes, text, or children.
🔠
Attribute Sorting
Alphabetize attributes on every element for consistent diffs.
🔧
Auto-Fix
Repairs unescaped ampersands, curly quotes, and stray whitespace.
🔍
Search
Find tags, attributes, or text instantly with match highlighting.
📊
Document Stats
Element count, attribute count, max depth, comments, and file size at a glance.
🕘
Local History
Every format/validate run is saved to your browser only, one click to reload.

Frequently Asked Questions

No. Formatting only changes whitespace, indentation, and line breaks. The element structure, attributes, and text content remain the same.

The Fix button repairs common issues like unescaped ampersands, smart quotes, and stray trailing content, but structural problems such as mismatched tags need manual correction first.

Well-formed XML follows basic syntax rules: matched tags, quoted attributes, one root element. Valid XML additionally conforms to a schema (XSD) or DTD. This tool checks well-formedness, not schema validation.

No. Parsing, formatting, validation, and conversion all run locally in your browser using the native DOMParser. Nothing is sent to or stored on our servers.

The encoding declaration is written exactly as selected, and downloads apply a best-effort single-byte conversion for those legacy encodings. Characters outside the Latin-1 range are replaced with "?", since browsers only natively support UTF-8 encoding/decoding.

Normalize collapses all whitespace in text nodes to single spaces and trims the ends. Trim only removes leading/trailing whitespace. Trim Whitespace-Only collapses text nodes that are pure whitespace but leaves other text untouched. Preserve keeps text exactly as-is. Collapse Blank Lines reduces repeated blank lines to one.

Yes. Switch the output view to JSON to get a structured JSON representation, with attributes prefixed by @ and text content under #text where an element has both attributes/children and text.

Yes. CDATA sections are preserved exactly as written. Comments are preserved by default, or can be stripped entirely with the Remove Comments option.

There's no fixed server-side limit since everything runs in your browser. Very large XML files depend on your device's available memory, and the tree view is not virtualized so extremely large documents may render slowly.

Related developer tools

Browse Other Categories

Support EaseDev Studios

All tools are free. If they've saved you time, consider supporting us.

Buy Us a Coffee

A quick one-time gesture that means a lot.

Buy a Coffee →
🎗️

Become a Patron

Support us monthly and help build more tools.

Join on Patreon →