Notepad++

How to Format XML in Notepad++ (XML Tools Plugin – Free, 2026)

How to Format XML in Notepad++ (XML Tools Plugin – Free, 2026)

Notepad++ highlights XML but doesn’t format it. For that you install the XML Tools plugin from Plugins Admin and run Plugins > XML Tools > Pretty print, which supplies the line breaks and indentation.

Where the indentation comes from is easy to miss. According to the plugin’s source code on GitHub, it reads the active tab’s settings and uses either a tab character or spaces equal to the indent size. So tabs versus spaces is set in Notepad++ preferences, not in the plugin. The same menu also runs the syntax check, and Linearize reverses the formatting.

How to format XML in Notepad++ with the XML Tools plugin

YouTube player

There’s no built-in XML formatter in Notepad++, so the plugin goes in first. After that, open the file and run Pretty print. One pass adds the line breaks and indents every nested element.

  1. Open Plugins > Plugins Admin.
  2. Search for “XML Tools”, tick it, click Install and confirm the restart.
  3. Open the XML file, or paste the raw XML into a new tab.
  4. Run Plugins > XML Tools > Pretty print.
  5. Read the result. If nothing changed, run Check XML syntax now and fix the first error it reports.

XML Tools is a free plugin by Nicolas Crittin (morbac on GitHub). According to the project README, it runs on MSXML and also handles syntax checks, XSD and DTD validation, tag auto-close, linearize and XPath evaluation. As of November 2026, 3.1.1.13 is still the latest release on the project’s GitHub releases page.

Plugins Admin is the standard install route. The Notepad++ community FAQ notes that the old Plugin Manager became obsolete at v7.6.3 (January 2019) and can drop plugins into the wrong folder, which is why they never show up in the menu.

Language mode matters a little too. Since release 3.1.1.7, XML Tools switches the tab to the XML language after pretty printing (GitHub release notes, issue 120). On older builds, pick Language > XML first so coloring and code folding follow the new structure.

Pretty print only moves tags onto separate lines. It doesn’t repair broken markup, and a missing closing tag stays missing, as Notepad++ forum moderators point out.

Pretty print, indent attributes or linearize: which command fits?

YouTube player

Plain Pretty print fits most files. Switch to the indent-attributes variant when tags carry long attribute lists, use the indent-only variant when the line breaks are already right, and use Linearize to flatten a document back to compact form.

CommandWhat it doesBest for
Pretty printBreaks the document into lines and indents nested elementsMinified or single-line XML
Pretty print – indent attributesExtends the indentation to attributes as wellTags carrying many attributes
Pretty print – indent onlyKeeps the existing line breaks and fixes just the indentationFiles that already have good line breaks
LinearizeCollapses the formatted document back to compact formUndoing a pretty print, compact output

The menu label for the main command depends on your plugin version, and that trips people up when a tutorial doesn’t match their screen. Older builds call it Pretty Print (XML only – with line breaks), the name used in the plugin’s changelog (release 1.1.2). XML Tools 3.1.1.6 on Notepad++ 8.1.4 shows Pretty Print and Pretty Print – indent attributes, per the Notepad++ community forum. A 2023 freeCodeCamp walkthrough just says Pretty print. The current source on GitHub has Pretty print, Pretty print – indent attributes, Pretty print – indent only and Linearize.

The flatten command was spelled “Linarize” in older builds. The typo was fixed in release 2.4.12.

Older walkthroughs also tell you to copy external libXML DLLs into the Notepad++ folder. The plugin’s changelog records an installer that did exactly that (release 2.0, with the DLLs moved to Windows\System32 in release 2.1). Release 3.0.0 replaced libXML with MSXML, and the current README describes an MSXML-based plugin, so the DLL step belongs to the old version and you can skip it.

What is the keyboard shortcut for XML pretty print?

YouTube player

The default is Ctrl+Alt+Shift+B. The plugin’s changelog records it as the shortcut added to the line-break pretty print command in release 2.0, the current source still assigns it to Pretty print, and the 2023 freeCodeCamp tutorial lists the same combination.

Other commands carry their own defaults, so the answers you find online describe different commands rather than competing for the same one. Pretty print – indent attributes gets Ctrl+Alt+Shift+A (source and older Stack Overflow answers), and Linearize gets Ctrl+Alt+Shift+L (source). Pretty print – indent only has no default at all. Other combinations, such as Alt+Shift+F, appear nowhere in the changelog or the source.

The shortcut on your machine is whatever the Shortcut Mapper says. The Notepad++ user manual states that a plugin can propose a default, that you can add or override it in the mapper, and that the mapper’s message area flags a conflict when two commands share a combination.

To check or change it:

New to Notepad++ or just need a quick reference? Essential shortcuts, regex for Find & Replace, and advanced editing - including Ctrl+H, Column Mode, and Macro Recorder - is on one page in the Notepad++ Cheat Sheet.

  1. Open Settings > Shortcut Mapper.
  2. Switch to the Plugin commands tab.
  3. Find the XML Tools entry for Pretty print and read its shortcut.
  4. Select the entry and click Modify to assign a different combination.

How to control indentation with tabs or spaces

XML Tools reads the active tab’s indentation settings and uses them for the output. Tab characters give you tabs, and anything else gives spaces equal to the indent size, with 4 as the fallback when the width is zero or less (XML Tools source code on GitHub).

To switch the output to spaces:

  1. Open Settings > Preferences > Indentation.
  2. Select XML in the language list and untick Use default value.
  3. Set Indent Using to Space character(s) and pick the indent size.
  4. Run Pretty print again.

Older builds put the same switch under Preferences > Language, in a Tab Settings box with a Replace by space checkbox (Stack Overflow answers for Notepad++ 7.x).

Changing the setting doesn’t convert existing indents by itself, according to the Notepad++ user manual. Pretty print regenerates every indent, so one more run applies the new choice to the whole file.

Order trips people up here. In the plugin’s source, the switch to the XML language runs after the formatting call, so if you set XML-specific indentation, pick Language > XML before the first run. Otherwise that first pass uses the tab’s old settings.

Line endings are simpler. The output follows the tab’s end-of-line mode (CR, LF or CRLF), so a CRLF document stays CRLF.

For files that already have good line breaks, use Pretty print – indent only, which keeps existing breaks and fixes just the indentation (XML Tools source code).

Checking XML syntax before you format

YouTube player

Run Plugins > XML Tools > Check XML syntax now on any file you didn’t write yourself. It reports errors such as an unclosed tag, and the XML Tools menu has First error, Previous error, Next error and Last error commands for walking through them.

Well-formedness and validity are separate checks. Check XML syntax now tests the first, while Validate now tests the document against an XSD schema or a DTD (XML Tools README). The README lists XSD and DTD validation as one feature, and when the document declares no schema, a plugin dialog asks you to pick an XSD file.

Does pretty print need well-formed XML? The sources disagree, mostly because they describe different plugin generations. The plugin changelog says release 2.3.3 removed the syntax check before pretty print, except in libXML mode, and release 3.0.0 then replaced libXML with MSXML. Older tutorials say the libXML option formats cleanly only when the file is 100% well-formed (appuals). The changelog lists no check before pretty print on current builds, so the syntax pass is a step you run yourself.

With Enable XML syntax auto-check on, the plugin checks before each save instead of while you type (changelog, release 2.0).

Why XML formatting fails in Notepad++ and how to fix it

Formatting usually fails for dull reasons. A read-only tab, the wrong plugin build, an XML Tools release older than 3.1.1.13, the Apply to all open files option, or a file above 2GB will account for most of it.

SymptomCauseFix
Pretty print does nothingRead-only tab, which the plugin skipsPaste the XML into a new tab
Menu missing, or “Cannot load 32-bit plugin” (or 64-bit)XMLTools.dll build does not match 32-bit or 64-bit Notepad++Install through Plugins Admin, or download the matching build
Crash on open, frozen save, Validate now showing an access violationXML Tools older than 3.1.1.13 on Notepad++ 8.3.x or 8.4Update to 3.1.1.13
Other open tabs get reformattedApply to all open files is checkedUncheck it in the XML Tools menu
Hang or crash on very large filesSupport above 2GB is unfinishedTurn on Allow huge files, or use a command-line formatter

The version bugs have different roots. After Notepad++ 8.2.1, an internal data structure grew to support files over 2GB, and plugins built against the old size broke, XML Tools among them (a plugin contributor, in XML Tools issue 154). The freezes on save and syntax check came from something else entirely. The plugin author traced them to unoptimized text conversion for UTF-8 files (XML Tools issue 152).

XML Tools 3.1.1.11 and 3.1.1.12 added compatibility changes for the structure change. Release 3.1.1.13 fixed an access violation, the UTF-8 syntax-check freeze and an infinite loop in the StringXml pretty print engine, per the plugin release notes. A roughly 49,000-line XSLT left Notepad++ 8.3.3 unresponsive on Save As, and 3.1.1.13 cleared it (XML Tools issue tracker).

When 3.1.1.13 came out in April 2022, Plugins Admin still offered the previous release. The author wrote that it would list 3.1.1.13 only after a plugin-list pull request reached a Notepad++ release, which is why many users installed it by hand.

On file size, release 3.1.1.12 fixed a crash when loading files over 2GB, and its notes say XML Tools is not 100% ready for them. The Allow huge files option has existed since release 2.4.11.

To isolate a crash, start Notepad++ with notepad++.exe -noPlugin, then add XML Tools first and the other plugins after. In one 8.4 report the culprit was ColumnTools 1.4.3.1, fixed by updating to 1.4.4.1 (Notepad++ forum).

How to install XML Tools manually

YouTube player
  1. Open ? > Debug Info to see whether Notepad++ is 32-bit or 64-bit.
  2. Download the matching XMLTools release from the project’s GitHub releases page.
  3. Create a folder named XMLTools inside the Notepad++ plugins folder (typically C:\Program Files\Notepad++\plugins).
  4. Copy XMLTools.dll into that folder and restart Notepad++.
  5. Look for XML Tools under the Plugins menu.

If Notepad++ still calls the DLL incompatible, unblock the file in its Properties dialog. The NppMarkdownPanel README documents that Windows blocks downloaded DLLs by default.

XML Formatting in Notepad++ FAQ

How do I format just a selection of XML?

Select the fragment and run Pretty print as usual. XML Tools formats only the selected text and replaces it in place, while an empty selection formats the whole tab (XML Tools source code).

Once your XML is properly formatted and validated, it becomes much easier to transform and integrate into other systems. If you need to import XML into a relational database or convert complex structures into SQL-ready tables, using a reliable XML-to-SQL converter like Flexter, can automate the entire process and save hours of manual cleanup.

Can Notepad++ pretty print XML automatically when a file opens?

Not with a built-in setting. XML Tools has no format-on-open option, but the PythonScript plugin can trigger the command with notepad.runPluginCommand, using the exact menu label of your XML Tools version, as Notepad++ forum users show.

Does pretty print change anything besides whitespace?

Yes, in one case. With the plugin’s pretty print auto-close option on, empty elements such as <data></data> become <data/> (plugin changelog and source code). That option is separate from the Tag auto-close toggle in the menu. Apart from that, only the whitespace between tags changes.

Elements marked xml:space="preserve" keep their whitespace when the plugin’s preserve option is on, supported since release 3.1.1.5.

Which plugins other than XML Tools can format XML?

Older Stack Overflow answers name TextFX and UniversalIndentGUI, so confirm they appear in Plugins Admin on your build before relying on them. For batches of files, Notepad++ forum moderators point to command-line formatters instead.

Confirming Formatted XML Is Safe to Save

YouTube player

Save only after a backup holds the original and Check XML syntax now passes on the result. Pretty print rewrites the whole document in place, so the copy has to exist before the first save.

  1. Set Backup on save to Verbose in Settings > Preferences > Backup.
  2. Run Pretty print, then save.
  3. Run Check XML syntax now on the saved file.

Verbose is the right setting because Simple backup keeps one previous version only. A second save overwrites the .bak file with the formatted text, and the original is gone (Notepad++ user manual).

The trade-off is clutter. Verbose backup writes one dated copy per save into an nppBackup subfolder beside the file, unless a custom backup directory is set.

Bogdan Sandu

Stay sharp. Ship better code.

Every week: one curated article, one tool worth knowing, one tip you can use tomorrow. No noise, no padding.