XML Formatting Guide: Make Sitemaps, Feeds, and Configs Readable
XML still runs a surprising amount of the web: sitemaps, RSS and Atom feeds, SVG graphics, Office documents, and countless configuration files. Served minified, they are a single unreadable line; one malformed tag can break a feed or get a sitemap rejected. An XML formatter pretty-prints the document with clean indentation, and the free tool on ZeroFee Tools validates it first, reporting errors in plain language.
Choose 2-space, 4-space, or tab indentation, and the tool handles declarations, comments, CDATA sections, and self-closing tags correctly. Debugging a sitemap? Generate a fresh one with the sitemap XML generator, then format it here to inspect every URL entry. Working with JSON APIs instead? The JSON formatter is the equivalent tool, and because the tool validates before formatting, it doubles as a quick well-formedness checker for any XML document you handle. Large documents are fine too, since everything is processed locally with no upload size limits.
What does it mean for XML to be well-formed?
Well-formed XML follows strict syntax rules: exactly one root element, every opening tag matched by a closing tag, quoted attribute values, proper nesting without overlap, and special characters escaped as entities. The formatter validates these rules first and refuses to format documents that break them, showing the parser error instead.
Well-formedness is XML contract with every parser on earth: a document either meets all the rules or it is not XML at all. There is no close enough. That is why a single unescaped ampersand in a URL inside a sitemap can invalidate the entire file and cause search engines to reject it.
The formatter runs your document through a real XML parser before touching the layout. If the document is well-formed, you get clean indented XML. If not, you get the parser error message telling you what is wrong and where, which is far more useful than a silent failure. Fix the reported issue and format again; the loop is fast because everything happens locally with no upload.
A practical tip: when a document fails validation, the reported error usually points near the problem but not exactly at it. Look just before the reported position for the unclosed tag or unescaped character; parsers typically notice the break one token late.
How do I debug an XML sitemap or RSS feed?
Paste the sitemap or feed into the formatter and press Format. Pretty-printing reveals the structure instantly: you can spot a missing closing tag, an unescaped ampersand, or a bad character long before a search engine or feed reader complains. Validate first, fix the reported error, and re-format until the whole document is clean.
Sitemaps and feeds are usually generated by software and served minified, which makes debugging them painful when something goes wrong. A sitemap with one malformed url entry may be partially ignored; an RSS feed with mismatched tags may not render at all. Formatting turns the wall of text into a readable tree where each entry sits on its own indented lines.
The built-in sample loads a sitemap-style document so you can see the expected shape immediately. Compare your file against it: every url entry should contain a loc element, special characters in URLs must be entity-escaped, and the document needs exactly one root element. If you are building a sitemap from scratch, the sitemap XML generator creates a valid one, and this formatter lets you verify it visually.
After formatting, also glance at the declaration line: the encoding attribute should match the actual file encoding, usually UTF-8. A mismatch here produces garbled characters that look like a formatting problem but are really an encoding one.
Does formatting preserve CDATA sections and comments?
Yes. The formatter keeps CDATA sections, comments, the XML declaration, and processing instructions intact, placing them correctly in the indented output. Self-closing tags stay self-closed rather than being expanded. Only insignificant whitespace between elements changes, so the document means exactly the same thing.
CDATA sections exist to protect content that would otherwise need heavy escaping, such as HTML inside an RSS description or code samples in documentation XML. A formatter that mangled them would corrupt the document, so this one treats their contents as untouchable and indents only around them.
Comments and the XML declaration get the same respect: they are preserved exactly as written and positioned sensibly in the output. Self-closing tags are not rewritten as open-close pairs, which keeps SVG files and sitemap image extensions identical in meaning. The result is safe to save over the original or feed back into whatever system produced it.
One caveat: formatting normalizes insignificant whitespace, so if your pipeline compares files byte-for-byte, expect cosmetic diffs after a format pass. Compare parsed structure, not raw bytes, when checking that a formatted document still matches the original.
How to format XML online in 4 steps
- Paste your XML. Drop in a sitemap, RSS feed, SVG file, or config, or press Sample to load a sitemap-style document instantly.
- Choose your indentation. Pick 2 spaces, 4 spaces, or a tab from the indent selector to match your project style.
- Press Format. The tool validates the document first: well-formed XML gets clean indentation, and broken XML gets a plain-language parser error.
- Copy the output. Press Copy output to grab the formatted XML, or Clear to start over with a new document.
5 practical XML formatting tips
- Escape ampersands in URLs. A raw & inside a sitemap URL invalidates the whole file; write & instead and let the formatter confirm the document is well-formed.
- Format before diffing. Comparing two minified XML files is hopeless. Format both first, then diff the readable versions to see real changes.
- Check the root element. Concatenated fragments often produce two roots, which is illegal; the validation error will point you at it.
- Keep CDATA for messy content. When element text contains lots of special characters, wrapping it in CDATA beats escaping each one.
- Validate feeds after every CMS change. Plugin updates love to break RSS output; a quick format catches mismatched tags before subscribers notice.
- Pretty-print before submitting sitemaps. A formatted sitemap is easier to proofread for bad URLs and wrong dates before you hand it to a search engine.
Frequently asked questions
Is this XML formatter free?
Yes. Format unlimited XML documents with no account and no limits. It runs entirely in your browser, so sitemaps, feeds, and configs are never uploaded anywhere. Large documents are fine too.
What does "not well-formed" mean?
It means the document breaks XML syntax rules: mismatched tags, unclosed elements, multiple roots, or unescaped special characters. The formatter shows the parser error so you know exactly what to fix.
Does it preserve CDATA sections and comments?
Yes. CDATA sections, comments, the XML declaration, and processing instructions are kept intact and positioned correctly. Self-closing tags stay self-closed; only whitespace between elements changes. Nothing is ever stripped or rewritten.
Can I change the indentation?
Yes. Choose 2 spaces, 4 spaces, or a tab from the indent selector before pressing Format. The whole document is re-indented consistently with your choice. Your selection applies to every nested level.
Is my XML uploaded anywhere?
No. Parsing and formatting happen locally in your browser. Your documents are never sent to a server, which makes the tool safe for private configs and unreleased feeds. Everything stays on your machine.
Ready to try it yourself? It's free, no signup required.
Try the free XML Formatter →