Free tool

XML Formatter and Checker with One-Click Repairs

A sitemap, a feed or an export file arrives as one long line, and one stray character stops it from loading. Paste it in, see it laid out with colour and line numbers, and get a plain sentence about any mistake.

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 the parser built into your browser and never uploaded or saved. The only thing kept on this device is the set of layout options you chose.

Opening a sitemap, a feed or an export

Press Paste, type into the Input box, open a file, or use Example. The Result side offers two views, XML and JSON. In the XML view, choose Formatted for a readable layout or Minified for the shortest version, and the output is coloured and numbered, with a slash key for search.

Very large files are kept out of the text box so the page stays quick. A small notice says so, and the result still appears on the right. You can choose to edit the file in the box anyway if you really want to.

Shortcuts are Command Enter to format, Command Shift Enter to minify, Command S to save and Command Shift C to copy, with Control and Alt on Windows.

Layout options worth knowing

OptionChoices
Indent2 spaces, 3 spaces, 4 spaces or tabs
AttributesAll on the tag line, one per line when a tag is long, or one per line when there are two or more
Empty elementsShort form such as br with a slash, or open and close tags
Comments when minifyingKeep them, or tick the box to remove them

Text mixed with tags, such as a paragraph with a bold word inside it, is left as written, because adding line breaks there would change the words. The same applies to anything inside an xml:space preserve section. The DOCTYPE line, comments, CDATA blocks and processing instructions are all kept.

When the file will not load

The check is done by your browser's own XML parser, which is strict. A mistake appears in plain words with its line and column, and the line is marked in the input box. Four slips can be repaired with one click, and each repair can be undone.

  • A bare ampersand in text, which XML needs written as an entity.
  • HTML names such as the non-breaking space entity, which plain XML does not know.
  • Text before the XML declaration at the very start of the file.
  • Two root elements, where XML expects exactly one.

Other problems, such as a tag that was never closed, are shown but not guessed at, because the right fix depends on what you meant.

Switching to JSON for a quick look

The JSON tab restates the XML as JSON, which is useful when the data has to go into a script or a modern tool. XML and JSON do not map one to one, since XML has attributes and mixed text that JSON has no direct place for, so check the result before relying on it. For a closer look at the JSON side, the JSON formatter lays it out further.

Why site owners meet XML

Sitemaps and many content feeds are XML files. A single broken character in a sitemap can make a search engine skip the file. We include checking those files in our website redesign SEO checklist, since a new site often brings a new sitemap with it.

Two habits help with XML files that matter to a site. First, keep a copy of the original before formatting, since a minified version is for machines and a formatted one is for review. Second, after you fix a sitemap, load it in a browser once more to confirm it opens without an error.

Formatting never changes tag names or attribute values. If the formatted output looks different in meaning, the cause is nearly always text mixed with tags, which this tool deliberately leaves exactly as you wrote it.

Frequently asked questions

How do I format XML?

Put the XML in the left box. The laid-out version appears at once on the right, and you can choose the indent and how attributes are placed.

Why does my XML show an error?

The page tells you the line and column. Common reasons are an unclosed tag, a bare ampersand, or two root elements in one file.

Does formatting change my data?

Formatting adds line breaks and spaces between tags, but text mixed with tags is left alone so words are not altered.

What does minify do?

It removes the spacing between tags so the file is as short as possible. You can also drop comments while doing so.

Can I convert XML to JSON?

Yes, use the JSON tab. Check the result, because attributes and mixed text do not have an exact JSON equivalent.

Is my file uploaded?

No. Your browser reads it locally and nothing is saved.

More free tools

  • JSON formatter: Format, minify, validate and repair JSON, browse it as a tree, or convert it to YAML or CSV.
  • YAML formatter: Check and tidy YAML, keep comments, and view it as JSON, a tree or compact flow style.
  • Diff checker: Compare two texts or files side by side, merge changes and export a diff.
  • Robots.txt generator: Build or load a robots.txt, add bot rules and test any path against it.
  • HTML viewer: Preview pasted HTML live at phone, tablet and laptop widths, with a console, format and minify.