code formatting - How do I format XML in Notepad++_ - Stack Overflow
code formatting - How do I format XML in Notepad++_ - Stack Overflow
PUBLIC Asked 12 years, 3 months ago Modified yesterday Viewed 1.9m times
Questions
I have Notepad++ and I got some XML code which is very long. When I pasted it in
Tags The Overflow Blog
Notepad++ there was a long line of code (difficult to read and work with).
Users 2012 Stack Gives Back 2022!
I want to know if there is a simple way to make the text readable (by readable I mean
Companies properly tabbed code). Commit to something big: all about
monorepos (Ep. 527)
COLLECTIVES I can do it manually, but I want a permanent solution to this as I have faced this several
Featured on Meta
Explore Collectives times. I am sure there is a way to do this as I have done it once before a couple of years
back, maybe with Visual Studio or some other editor, I don't remember.
2022 Community-a-thon Recap
TEAMS
But can Notepad++ do it? Temporary policy: ChatGPT is banned
Stack Overflow for
Teams – Start
collaborating and notepad++ code-formatting
sharing organizational 34 people chatting
knowledge.
Share Improve this question edited Apr 6, 2019 at 1:35 asked Oct 18, 2010 at 16:35
Linked
Follow Peter Mortensen happyhardik
30.8k 21 104 125 24.5k 7 45 60
2 How to Structure the XML code
2 @S.Roshanth seems to be resolved in latest 8.x versions of 64-bit Notepad++. Just use Plugins ->
5 Notepad++ XML Display on seperate lines
Plugins Admin and search for XMLTools and install there. The menu options to format then appear in like Internet Explorer Display Of XML
Plugins -> XML Tools. – Shiv Sep 16, 2021 at 6:58
-2 Why does XML look differently in
Add a comment notepad++ and notepad?
Try Plugins -> XML Tools -> Pretty Print (libXML) or (XML only - with line breaks Ctrl + 1 How to make pretty print in programmer's
Alt + Shift + B )
notepad
In my experience, libXML gives nice output but only if the file is 100% correctly formed. Related
Share Improve this answer edited Apr 18, 2019 at 23:32 answered Oct 18, 2010 at 16:48 2575 How do you display code snippets in MS
erjiang Word preserving format and syntax
Follow
43.8k 10 62 100 highlighting?
34 If you get the "Errors detected in content" error when trying to use this plugin, try XML Tools -> 522 How to turn off the Eclipse code formatter
Check XML syntax now. I had an issue where the encoding was specified as UTF-16 but was actually for certain sections of Java code?
UTF-8. Changing the encoding attribute in the XML file fixed the problem. – Mirza Dobric Jul 20,
2012 at 18:33 435 Removing empty lines in Notepad++
159 And if your Plugins Manager can't find XML Tools because you are behind a proxy at work, 674 Removing duplicate rows in Notepad++
download it from here sourceforge.net/projects/npp-plugins/files/XML%20Tools Then copy
XMLTools.dll to the plugins directory and the rest of the four dlls to the root Notepad++ directory. 711 How To Auto-Format / Indent XML/HTML in
– Amit Naidu Dec 4, 2012 at 19:06 Notepad++
16 Ad if you cannot see any plugin available, go to "updates" and update your plugin manager. 421 How do I configure Notepad++ to use
– Surasin Tancharoen Feb 14, 2013 at 13:50 spaces instead of tabs?
38 ...AND if you don't have a Plugin Manager plugin, you can get it from here: 494 Notepad++ add to every line
github.com/bruderstein/nppPluginManager/releases – Chris W Jan 18, 2017 at 21:50
988 How do you format code in Visual Studio
Code (VSCode)?
Show 20 more comments
157 install it and then Ctrl + Alt + Shift + B OR the option for XML Tool above shows up. Kyber and Dilithium explained to primary school
students?
Share Improve this answer Follow edited Jun 25, 2020 at 5:56 answered Jun 25, 2012 at 21:00 Do journal editors/referees expect relatively
unknown authors to provide evidence of counsel
SandstormNick abhi from an expert when submitting a paper?
1,501 14 23 1,587 1 9 2
Do you really need a capacitor from pin 5 to
Add a comment ground in an astable 555 timer circuit?
Is it Nebuchadnezzar or Nebuchadrezzar?
Question feed
Share Improve this answer Follow answered Dec 24, 2015 at 10:32
iCrazybest
2,815 2 23 24
2 great answer, however i don't have the "Plugin Manager" o_O Can someone help? Was it removed
meanwhile? – fl0w Feb 26, 2018 at 15:43
3 worked for me..For the new versions of notepad++ have plugin admin instead of plugin manager
– Jayani Sumudini Jul 30, 2019 at 11:35
Add a comment
45 If you can't try with Eclipse, do right button, source, and correct indent.
Share Improve this answer Follow edited Apr 6, 2019 at 1:43 answered Oct 18, 2010 at 16:45
Peter Mortensen Torres
30.8k 21 104 125 5,290 4 25 26
2 Thanks for the answer but I am not able to find Tidy: reindent XML in my TextFX Html Tidy menu. Can
you tell me what I am missing? – happyhardik Oct 20, 2010 at 12:57
4 If you have no global "TextFX" option then you need to install the plugin named TextFX. But that's not
enough, apparently 6.x versions are also missing the libtidy.dll download so you have to go through
hoops to get it. Then you will have a Tidy: reindent XML option (I presume) – rogerdpack Nov 26, 2013
at 21:41
1 I have such option but it does nothing (and gives no error message). – Danubian Sailor Feb 10, 2014 at
9:27
For anyone else wondering, the hoops mentioned by @rogerdpack are discussed here
– Steve Chambers Nov 16, 2014 at 21:04
1 The main issue I have with TidyXML is that it's maddeningly slow for any file over a meg or two. – T.S
Aug 2, 2018 at 11:16
Plugins -> XML Tools -> Pretty Print (libXML) or Ctrl + Alt + Shift + B
38
You probably need to install the plugin:
Then copy XMLTools.dll to the plugins directory and external libraries (four dlls) into the
root Notepad++ directory.
Share Improve this answer Follow edited yesterday answered Nov 15, 2013 at 13:39
dregad jbigman
1,075 8 19 1,170 11 24
Add a comment
Here are most of plugins you can use in Notepad++ to format your XML code.
22 UniversalIndentGUI
(I recommend this one)
TextFX
(this is the tool that most of the users use)
XML Tools
(customized plugin for XML)
Share Improve this answer Follow edited Nov 18, 2015 at 21:08 answered Sep 5, 2014 at 4:27
Peter Mortensen Sameera R.
30.8k 21 104 125 4,276 1 34 53
1 When I use UniversalIndentGUI to indent one big line of XML, it doesn't work. I have no change. – Alex
Mar 20, 2015 at 10:18
1 I checked again and it doesn't work just after installing the plugin. You have to edit settings of the
plugin, go to XML Indent options and check the Force newline option. Now it works. Thanks for the
tips because it helps for XML not 100% correct :) – Alex Mar 23, 2015 at 11:16
UniversalIndentGUI worked for me where other options have failed, not sure why except that the XML
file I was prettifying was 40MB plus. It was also extremely quick. Props to Alex for the XML force
newline option tip. – Branstar Sep 10, 2015 at 9:25
TextFX has been phased out - from TextFX's Future: "... bid farewell to an aging workhorse that has
served the community well." – Peter Mortensen Apr 6, 2019 at 1:47
Add a comment
All the previous answers do not define how to add the plugin manager in your Notepad++
installation.
18
This is for the folks who do not see the the plugin manager in the plugin tab
Download the plugin manager from this link - this is for the 64-bit plugin manager. Once you
download the plugin manager, paste in the plugin folder. This is was my location of plugin
folder: C:\Program Files\Notepad++\plugins
After pasting the .dll file restart Notepad++. Now you can install any plugin. To install a
plugin, click on the plugin tab, then go to plugin manager and select the plugin whatever you
want.
Share Improve this answer Follow edited Apr 6, 2019 at 1:54 answered Sep 4, 2018 at 8:27
Peter Mortensen Varun
30.8k 21 104 125 6,451 19 82 117
Add a comment
For best results, you should use both TextFX XML tidy and XML tools pretty print. Here's how
and why:
16
1.TextFX -> TextFX HTML Tidy -> Tidy: reindent XML
TextFX has the benefit of wrapping long lines, which XML Tools does not do, but it doesn't
indent those new lines correctly.
XML Tools complements TextFX by indenting the newly wrapped lines nicely.
Share Improve this answer Follow edited Nov 18, 2015 at 21:01 answered Sep 4, 2012 at 18:43
Peter Mortensen Some Noob Student
30.8k 21 104 125 13.9k 13 64 103
I was trying to compare 2 different environment config files...that had 10 or so different settings...but
the xml attributes were on one-line in one file and on different lines in the other xml file. Only by doing
both of these did the actual differences pop up on a file-compare tool. Thanks. – granadaCoder Aug
17, 2015 at 21:51
1 TextFX has been phased out - from TextFX's Future: "... bid farewell to an aging workhorse that has
served the community well." – Peter Mortensen Apr 6, 2019 at 1:46
Add a comment
11 Plugins
Plugin manager
Show plugin manager
Install
Restart Notepad++
XML tools
Pretty print (XML only -- with line breaks)
Share Improve this answer Follow edited Nov 18, 2015 at 21:04 answered May 15, 2013 at 16:33
Peter Mortensen Michael B
30.8k 21 104 125 111 1 2
Add a comment
11
Cannot load 32-bit plugin, XMLTools.dll is not compatible with the current version of
Notepad++
Here you can find a working version for Windows 10 x64: Xml Tools 2.4.9.2 Unicode
Note: It's the only version I've found working on Windows 10 Professional x64.
Add a comment
select the entire XML file content and click on pretty print
or
The option is in the menu Plugins > XML Tools > Pretty print (believe it or not, I couldn't find it). It's
not necessary to select the entire XML – Metafaniel Aug 20, 2022 at 3:01
Add a comment
Notepad++ v6.6.3 with plugin "XML Tools" and shortcut Ctrl + Alt + Shift + B works
fine.
6
Share Improve this answer Follow edited Nov 18, 2015 at 21:07 answered Jul 23, 2014 at 2:26
Peter Mortensen hoggar
30.8k 21 104 125 3,609 5 29 39
Add a comment
You can find details here To Quickly Format XML using Pretty Print (libXML)
If you run Notepad++ and look in the Plugins menu, you’ll see that the XML Tools aren’t
there:
2. Unzip the file and copy the XMLTools.dll to the Notepad++ plugins folder (in the
example above: C:\Program Files (x86)\Notepad++\plugins):
3. Re-start Notepad++ and you should now see the XMLTools appear in the Plugins menu.
4. Unzip the ext_libs.zip file and then copy the unzipped DLLs to the Notepad++
installation directory (in the example above: C:\Program Files (x86)\Notepad++).
5. Re-start Notepad++ and you should finally see the proper XML Tools menu.
6. The feature I use the most is “Pretty print (XML only – with line breaks)”. This will format
any piece of XML with all the proper line spacing.
Share Improve this answer Follow edited Mar 10, 2018 at 14:18 answered Jul 3, 2015 at 6:01
Andrea Spartan
11.4k 17 63 68 2,982 6 25 28
Add a comment
There is no such a thing like TextFX in Notepad++, not in the latest version at least. This is
one of the reasons I'm still with DreamWeaver even if it is driving me insane being slow and
5 unresponsive from time to time...
Share Improve this answer Follow edited Apr 6, 2019 at 1:44 answered Jan 11, 2012 at 3:12
Peter Mortensen Snowalker
30.8k 21 104 125 309 1 7 16
yes, things have changed a lot in the new version, but I was still un able to solve it out! – happyhardik
Jan 11, 2012 at 10:15
4 for versions 5.9.x, go to plugins -> plugin manager -> show plugin manager and you can add it from
here – Ralph Willgoss Apr 4, 2012 at 11:06
1 The ability to add or not add certain features might be weird at first, BUT that is why so many people
USE Notepad++ over much bulkier products like DreamWeaver! YOU decide how thin or fat your
program is rather than have the kitchen sink load all day every day... (and, this should have been a
comment rather than a submitted answer) – BillyNair Mar 5, 2015 at 23:11
Add a comment
The location of XML tools has changed slightly since this question was first asked.
Plugins tab
Plugins Admin...
Plugins Admin dialog appears with Available plugins tab as the default
This will close Notepad++ while it installs and then restart it automatically.
Plugins tab
Share Improve this answer Follow answered Jun 24, 2020 at 5:24
SandstormNick
1,501 14 23
Add a comment
4 If the XML is invalid, the answer is apparently 'no'. I tried Notepad++ with the Tidy2 and
XMLTools plugins. Both give errors similar to "errors encountered, please fix". If you don't care
about errors, that's a PITA.
Instead, open it in visual studio then edit -> advanced -> format document. Quick and pretty.
Share Improve this answer Follow edited Nov 18, 2015 at 21:02 answered Apr 25, 2013 at 20:02
Peter Mortensen phish_bulb
30.8k 21 104 125 87 8
2 XMLTools will complain if there is no root element. If your XML is otherwise valid, you can fix it by just
adding something like <root> / </root> at the top/bottom. – John Fouhy Dec 16, 2013 at 0:45
Add a comment
The latest version of Notepad++ x64 v7.6.2 on Windows 10 already moved the plugin
manager to 'Plugins Admin'.
4
Old versions of Notepad++ and plugin manager won't work.
Share Improve this answer Follow edited Apr 6, 2019 at 1:57 answered Jan 23, 2019 at 10:28
Peter Mortensen Denis Wang
30.8k 21 104 125 935 12 12
Add a comment
If your XML is imperfect, try this with the TextFX Characters plugin (install from Plugin
manager):
3
First, find a ">" to copy into the clipboard. Then select ALL your text, and then...
On the main menu: TextFX -> TextFX Edit -> Solit lines at clipboard char...
This will do a reasonable job, not perfect, but things will be readable, at least.
I had to do this with XML code stored in an SQL Server database, where the headers weren't
stored, just the XML body...
Share Improve this answer Follow edited Nov 18, 2015 at 21:06 answered Mar 20, 2014 at 17:46
Peter Mortensen Banzai
30.8k 21 104 125 31 3
TextFX has been phased out - from TextFX's Future: "... bid farewell to an aging workhorse that has
served the community well." – Peter Mortensen Apr 6, 2019 at 1:47
Add a comment
Since I see lots of comments about people having problems with the plugin, I thought I'd
mention the work around that I use.
3
I just use one of the online sites for XML viewing (I use https://codebeautify.org/xmlviewer,
but there are plenty out there) as follows:
I don't know if it qualifies as answering the OP's question exactly, but it's very simple and easy
for anyone who is having problems with the plugin.
Share Improve this answer Follow edited Apr 6, 2019 at 1:50 answered Jun 6, 2018 at 17:43
Peter Mortensen rsmith
30.8k 21 104 125 83 6
10 Only do this if your xml does not contain any sensitive/private data – Patman Jun 28, 2018 at 2:40
1 codebeautify stores the xml we paste there so it is better to avoid such tools. – mohsin.mr Jun 21,
2021 at 21:38
Add a comment
You can't, granted you don't have access to install plugins. But you probably have or can get
Eclipse (Visual Studio can do this too).
3
Ctrl + N (new file) → (choose XML file) → (paste your XML content) → Ctrl + Shift +
K (format)
If you want to format JSON NotePad++ can do this by default with Ctrl + Alt + m
Share Improve this answer Follow edited Jun 4, 2019 at 21:14 answered Nov 20, 2018 at 18:56
Philip Rego
505 4 20 33
Add a comment
UniversalIndentGUI did the job for me, once configured properly as described above.
2 TextFX would not install and run correctly on an old PC I have running Windows XP. There
are instructions above for manual installation of various DLL files, but I'd rather avoid any
manual installation.
<ClockStatus>1
</ClockStatus>
<ClockStatus>1</ClockStatus>
But the output is still much better than one long line!
Share Improve this answer Follow edited Apr 6, 2019 at 1:48 answered May 6, 2015 at 14:58
Peter Mortensen Ivan
30.8k 21 104 125 4,157 34 26
Add a comment
Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this
question. The reputation requirement helps protect this question from spam and non-answer activity.
Not the answer you're looking for? Browse other questions tagged notepad++
STACK OVERFLOW PRODUCTS COMPANY STACK EXCHANGE NETWORK Blog Facebook Twitter LinkedIn Instagram