Black Friday: 50% off every paid plan with code BF50. Ends 5 December.

See prices

Free tool

XML formatter, beautify, minify, check.

Paste XML or drop a file and it is checked and indented as you type. A mistake is explained in plain words and marked on its line, and common slips like a bare & can be fixed with one click. The result is coloured and searchable, as formatted XML, minified XML or JSON. Mixed text, the DOCTYPE, comments and CDATA are kept. Big files stay quick, and nothing is uploaded.

Need a custom tool, app or website? Contact us 
Input
Result

The formatted XML shows here.

Paste on the left, open a file, or press Example.

Options

Keys

  • Cmd Enter Format
  • Cmd Shift Enter Minify
  • Cmd S Download
  • Cmd Shift C Copy
  • / Search

Your XML is read by your browser's own parser. It is never uploaded or saved. Only your settings are remembered on this device.

Clean XML

Readable, small or checked.

01 / Format

Indented by level

Each element on its own line, indented by depth; short text stays on one line with its tags.

02 / Minify

Smallest size

Spaces between tags removed, for sending or storing.

03 / Check

Errors on their line

Your browser's XML parser finds the first mistake. The line is marked and the message is in plain words.

Guide

How to format XML, and find what breaks it.

An XML formatter takes XML that is squashed onto one line, or indented in a messy way, and rewrites it so each element sits on its own line, indented by how deep it is. This one can also minify XML back onto one line, or simply check whether it is well formed. The checking is done by your browser's own XML parser, so if the file will not parse here, it will not parse in most other software either.

How to use the XML formatter

  1. Paste your XML into the Input box, drop a file on it, or press Open file. Any XML works: .xml, .svg, .rss, .atom, .xsd, .xsl, .plist, .config, .kml, .gpx and more. Press Example to try it first.
  2. The result appears on the right as you type, coloured and with line numbers. The status line says how many elements and attributes it found and how deep they go.
  3. Pick an Indent (2, 3 or 4 spaces, or tabs) and how Attributes are laid out. Changes show at once.
  4. Switch between Formatted and Minified, or press JSON above the result to convert it.
  5. Search the result with the box above it. Enter jumps to the next match.
  6. Press Download to save the file under its own name, or Copy.

If the XML has a mistake, the result side explains it, shows the lines around it, and marks the line in the input in red. Show in the input puts the cursor right there.

Formatted, minified or JSON

Formatted is for reading. Each element gets its own line, indented by how deep it is. An element with only a short piece of text stays on one line, so <title>Dune</title> is not split over three lines. With Attributes set to one per line when a tag is long, a tag with many attributes is split so each one sits on its own line once the tag passes 100 characters.

Minified is for machines. It removes the line breaks and indentation between tags. Text inside elements is kept exactly as it was, spaces included. Tick Remove comments when minifying to drop comments too.

JSON turns the XML into JSON. Attributes become keys that start with @, such as "@id": "1". Text next to attributes or child elements goes in "#text". Elements with the same name become a list. Values stay as text, so 9.99 becomes "9.99" and nothing is lost.

Well formed is not the same as valid

The Check button tests whether XML is well formed: every tag is closed, tags nest properly, there is one root element, attribute values are quoted and special characters are escaped. That is the basic grammar every XML file must follow.

Valid XML goes one step further: it also follows a schema (an XSD or DTD) that says which elements are allowed, in what order, and what their values can be. This tool does not test against a schema. A file can pass Check here and still be rejected by a system that expects certain elements.

Common XML errors and how to fix them

ProblemExampleFix
Closing tag does not match<name>Ann</Name>XML is case sensitive. Make both tags exactly the same.
Tag never closed<item>PenAdd </item>, or write an empty element as <item/>.
Tags overlap<b><i>hi</b></i>Close the inner tag first: </i></b>.
Bare ampersand<co>Smith & Sons</co>Write &amp; instead of &.
Unquoted attribute<book id=1>Quote it: id="1".
Two root elements<a/><b/>Wrap everything in one outer element.
Something before the declarationA blank line or space before <?xmlThe declaration must be the very first thing in the file.

The line and column in the error point to where the parser gave up, which is often just after the real mistake. If the error is about a closing tag, look back up the file for the opening tag that was never closed.

One-click fixes

When the XML does not parse, the error box offers a fix if one of these is in the file. Each fix is listed by what it changes, and Cmd+Z (Ctrl+Z on Windows) in the input undoes it.

  • Change bare & to &amp;. An ampersand that does not start an entity is escaped. Text inside CDATA and comments is left alone.
  • Turn HTML names into numbers. Names like &nbsp; and &copy; exist in HTML, not XML. They become &#160; and &#169;, which every XML reader knows.
  • Remove what comes before <?xml. A space, a blank line or a hidden byte order mark before the declaration is removed.
  • Wrap it all in one <root>. When the text has two or more top level elements, they are wrapped in a single root element.

What the formatter keeps and what it changes

  • Comments, CDATA sections, processing instructions, the DOCTYPE and the XML declaration are kept.
  • Mixed text and tags, like <p>Hello <b>there</b></p>, stay on one line exactly as written, so no spaces between words are lost. Elements marked xml:space="preserve" are kept as written too.
  • Text inside an element that holds only text is trimmed of spaces at the start and end in the formatted view.
  • Attributes keep their order but are always written with double quotes.
  • Entities are read and written back in a form that means the same thing. A character written as a number, like &#169;, is written as the character itself.
  • The result is saved as UTF-8. If the declaration names another character set, such as ISO-8859-1, it is changed to UTF-8 to match, and the status line says so. Files in other character sets are read correctly when they declare it.

Big files

The result is drawn a screen at a time, so files of many megabytes scroll smoothly and search covers the whole file. A file over 3 MB is kept out of the input box, which would make typing slow, and its result shows on the right. Press Edit it here anyway if you need to change it. Reading a large file takes a moment, because the whole file has to be parsed first.

Keyboard shortcuts

Cmd+Enter formats, Cmd+Shift+Enter minifies, Cmd+S downloads, Cmd+Shift+C copies and / jumps to search. On Windows, use Ctrl for Cmd. Your indent, layout and other settings are remembered on this device. The XML itself is never stored.

On a Mac

macOS includes a command line tool called xmllint. Open Terminal and run xmllint --format file.xml to print an indented copy, or xmllint --noout file.xml to check a file and see only the errors. It is handy for files too large to paste into a browser.

Mac property list files (.plist) are often saved in a binary form, not as text. If a .plist opens here as garbled characters, convert a copy to XML first with plutil -convert xml1 copy.plist. That command rewrites the file you name, so run it on a copy.

Working with JSON instead? Use the JSON formatter. To see exactly what changed between two versions of a file, paste both into the diff checker.

Questions

Good to know.

How do I format XML?

Paste it or drop the file. It is formatted as you type, and you can download or copy the result.

How do I find an error in my XML?

Paste it. The result side explains the first error in plain words with its line and column, and the line is marked in red in the input. Show in the input puts the cursor on it.

Can it fix my XML?

For a few common slips, yes: a bare &, HTML names like &nbsp;, text before the declaration and two root elements. Each fix is offered only when it applies, and can be undone. Other mistakes, like a missing closing tag, need you to decide where it goes.

Does it keep comments, CDATA and the DOCTYPE?

Yes, and the XML declaration and processing instructions too. Minify can drop comments if you tick that option.

Can it convert XML to JSON?

Yes. Press JSON above the result. Attributes become keys starting with @, repeated elements become lists, and values stay as text.

Can it format SVG, RSS or plist files?

Yes, any well-formed XML.

Is my file uploaded?

No. It is read by your browser's own XML parser in this tab. Only your settings are remembered on this device.

What is the difference between well formed and valid XML?

Well formed means the XML follows the basic rules: closed tags, proper nesting, one root, quoted attributes. Valid means it also matches a schema such as an XSD or DTD. This tool checks well formed XML only.

Why does my XML say there is more after the root element?

Usually the file has more than one top level element, or stray text after the last closing tag. XML allows only one root element. The Wrap it all in one <root> fix does that for you.

Does formatting change my data?

Elements, attributes and text stay the same. In the formatted view, spaces at the start and end of text-only elements are trimmed. Mixed text and tags, and xml:space="preserve", are kept exactly.

How big a file can it handle?

There is no set limit. Files of many megabytes work; the limit is your computer's memory. Very large files take a moment to read.

Listed on

Listed on JustMacAppsMotionShine on Mac App IndexMotionShine on ScrollLaunchMotionShine featured on StartupBaseFeatured on FazierFeatured on Twelve ToolsMotionShine - Featured on Smol Launch