Formatting XML data means rebuilding the visual indentation of a document so every opening and closing tag sits at a depth that matches its real position in the tree. A well-formatted XML file shows the nesting at a glance — child elements are clearly indented under their parents, attributes line up, and the whole document reads top-to-bottom like an outline. A document that has not been formatted is often a single long line, or a block where the indentation no longer matches the actual structure, and reading or editing either of those by hand is tedious and error-prone. The work involved is purely mechanical: count the opens, count the closes, line them up at the correct depth, and preserve everything that lives between the tags. That description fits a tool-driven task rather than a human one, which is why XML formatting is almost always delegated to a beautifier that understands the language.
Notepad++ is a popular place to keep XML files because it colorizes tags, attributes, and text content, but the editor itself ships without a built-in XML beautifier. Out of the box, Notepad++ can only re-indent text using generic whitespace rules — it does not understand that an attribute value containing a > character is still inside the tag, that a CDATA section should be passed through untouched, or that a self-closing element should not be padded with extra whitespace. The conventional workaround is to install a third-party plugin such as XML Tools, which requires downloading files, placing them in the right plugin folder, and restarting the editor.
A faster path is to copy the XML out of Notepad++, paste it into a browser-based XML Formatter, choose an indentation style, and copy the cleaned result back. The round trip takes only a moment, and because the tool runs locally in your browser using JavaScript, nothing is uploaded. The rest of this article walks through exactly how to do that, what the formatter preserves, and when to use Minify instead of Format.

Why XML Data Ends Up Hard to Read
Most messy XML comes from one of three places. API responses from SOAP and REST services are typically delivered as a single minified line to save bandwidth — every byte of whitespace between tags is stripped before transmission. Configuration files like pom.xml, AndroidManifest.xml, ASP.NET web.config, and Spring beans are often auto-generated by build tools and inherit whatever indentation style the tool decided to use. Human edits leave their mark too: a developer opens a file in Notepad++, deletes one tag by hand, and the surrounding indentation no longer reflects the real nesting.
The result is the same regardless of source — a document where the eye cannot easily trace which closing tag matches which opening tag, and where finding a specific element means scanning a wall of characters. A formatter rebuilds the visual hierarchy so the structure becomes obvious again, element by element, line by line.
Format XML in Your Browser in Five Steps
The fastest way to clean up XML data from Notepad++ is to use the browser-based XML Formatter. Here is the full workflow.
- Paste or type your XML into the input box. Open the XML Formatter in your browser, select all the text in your Notepad++ document (Ctrl+A on Windows or Cmd+A on macOS), copy it (Ctrl+C / Cmd+C), and paste it into the input area. You can also paste XML that came straight from an API response or a configuration file.
- Pick an indentation style. Choose 2 spaces, 4 spaces, or a Tab per nesting level. Match the style your project uses so the formatted output can be dropped straight back into the file without creating a noisy diff.
- Click Format to pretty-print, or Minify to compress to one line. Format rebuilds the visual hierarchy with consistent indentation. Minify strips out the whitespace between tags and produces a single compact line — useful for shrinking payloads before sending.
- Review the result and read any error. If the XML is malformed, the formatter flags structural problems such as unclosed tags, mismatched closing tags, or unterminated comments and CDATA sections, often with a line and column. Fix the issue in your Notepad++ source and paste the corrected version back in.
- Click Copy to put the result on your clipboard. Paste it back into Notepad++ in place of the original block. Save the file and your XML is now cleanly indented.
Choosing 2 Spaces, 4 Spaces, or Tab
The indentation choice is not cosmetic — it changes how the formatted file looks inside version control, how it lines up against neighboring code, and how many columns the deepest tag occupies.
- 2 spaces is the default in many modern projects and keeps wide documents narrow. It is also the convention used by Google's XML style guide.
- 4 spaces is the long-standing default for Java, Spring, and .NET configuration, and gives the eye a stronger visual cue per nesting level.
- Tab matches what most editors produce natively and lets each developer choose their own visual width via their editor's tab-stop setting.
When in doubt, match whatever the rest of the file already uses. A consistent indent is easier to read than a mix of styles, and it produces smaller diffs when the file is committed.
What the XML Formatter Preserves
XML has several constructs that a naive find-and-replace beautifier gets wrong. The formatter is built around XML's tag-and-attribute model and handles each of these correctly.
- Attribute values containing > are parsed as part of the attribute rather than being read as the end of the tag.
- Self-closing elements like <br/> stay exactly as written.
- Comments (<!-- ... -->) are kept in place and indented alongside the surrounding elements.
- CDATA sections are passed through untouched, so the literal characters inside — including reserved symbols and markup-looking text — survive both formatting and minifying.
- The XML declaration (<?xml version="1.0"?>) and processing instructions stay on their own line at the top of the document.
- DOCTYPE declarations are preserved verbatim.
- Mixed content — an element mixing text with inline child elements, the kind you see in SVG text, XHTML, or documentation formats — is kept on a single line exactly as written, so no meaningful whitespace inside it is rewritten.
One thing to know: the formatter only re-indents the whitespace between tags. The only whitespace it normalizes is the leading and trailing whitespace of an element whose content is plain text only. If your document relies on xml:space="preserve", use Minify instead, which keeps all meaningful text exactly as-is.
Format vs Minify: When to Use Each
Format and Minify do opposite things and solve different problems. The table below compares the two directions.
| Aspect | Format (Pretty-Print) | Minify |
|---|---|---|
| Output shape | Multi-line, indented document | Single compact line |
| Indentation | 2 spaces, 4 spaces, or Tab | None between tags |
| Comments | Preserved and indented | Preserved in place |
| CDATA | Passed through untouched | Passed through untouched |
| Mixed content | Emitted verbatim on one line | Emitted verbatim on one line |
| Best for | Reading, editing, reviewing diffs | Sending over the wire, embedding in code, reducing payload size |
The choice depends on what you are about to do with the XML. If you are about to read or edit it, Format. If you are about to transmit it or embed it, Minify. Many developers keep a formatted copy for editing and a minified copy for shipping.
Browser-Based Formatting vs Installing a Plugin
The traditional route inside Notepad++ is to install the XML Tools plugin and use its Pretty Print shortcut. That works, but it has trade-offs compared with a browser-based approach.
| Aspect | Browser XML Formatter | Notepad++ XML Tools Plugin |
|---|---|---|
| Installation | None — open the page | Download DLLs, place in plugin folder, restart |
| Where it runs | Browser, using local JavaScript | Inside the Notepad++ process |
| Network access | Not required after first load | Not required |
| Privacy | XML never leaves the device | XML stays on the device |
| Error reporting | Line and column for common structural problems | Line and column for common structural problems |
| Indentation choices | 2 spaces, 4 spaces, Tab | Configurable in plugin settings |
| Editable inside Notepad++ | No — paste back in | Yes — applied in-place |
For Notepad++ users who format XML often, the plugin wins on convenience because the formatting happens in-place. For occasional formatting, the browser tool removes the install step entirely. Both end up at the same destination — cleanly indented XML. If you also work with HTML files in Notepad++, the same browser-based approach is described in Format HTML Code from Notepad++ Without Plugins.
Spotting and Fixing the Errors the Formatter Catches
Because the formatter parses your document as it formats, it can flag the mistakes that cause the most grief in real XML files. The errors below are the ones you are most likely to see, with what they usually mean in a Notepad++ editing session.
- Unclosed tag. An opening tag without a matching closing tag. Usually caused by deleting a line in Notepad++ without checking what came after it.
- Mismatched or stray closing tag. A closing tag with no matching opening tag, or one that closes the wrong element. Almost always a copy-paste error between files.
- Unterminated comment. A <!-- without a matching -->. Happens when text is truncated mid-comment by an external tool.
- Unterminated CDATA section. A <![CDATA[ without the closing ]]>. Common when large blocks of escaped data are moved between files.
- Unterminated processing instruction. A <? without the closing ?>. Affects the XML declaration and similar constructs at the top of the document.
The formatter is not a full XSD or DTD validator — it does not check your document against a schema, verify data types, or enforce namespace rules. Think of it as a tool that refuses to silently emit broken output rather than a compliance checker. For structural problems caught during reformatting, it gives you a friendly message and, where possible, a line and column to jump to inside your Notepad++ source.