Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

code formatting - How do I format XML in Notepad++_ - Stack Overflow

The document discusses how to format XML code in Notepad++, particularly for long lines that are difficult to read. It suggests using the XML Tools plugin for pretty printing and mentions other options like TextFX for reindenting XML. Users are advised to install the necessary plugins and provides shortcuts for formatting XML effectively.

Uploaded by

Kris Stefiduf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

code formatting - How do I format XML in Notepad++_ - Stack Overflow

The document discusses how to format XML code in Notepad++, particularly for long lines that are difficult to read. It suggests using the XML Tools plugin for pretty printing and mentions other options like TextFX for reindenting XML. Users are advised to install the necessary plugins and provides shortcuts for formatting XML effectively.

Uploaded by

Kris Stefiduf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

About Products For Teams Search… Log in Sign up

Home How do I format XML in Notepad++? Ask Question

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

99 Notepad++ htmltidy - unable to find


3 Configuring the XMLTools is bit tricky with latest versions. In Windows 10, Notepad++ version V6.6.8 libtidy.dll
I have configured XMLTools 2.4.7 successfully. Download the latest plugin from this link and follow
90 How to indent HTML tags in Notepad++
the instruction in install.txt > notepad-plus-plus.org/community/topic/125/… . – S.Roshanth Mar 28,
2017 at 8:20 28 Configure proxy settings in Notepad++ via
Plugin Manager
1 Current solution for the 64bit version: superuser.com/q/1239935/333622 – Raidri Mar 9, 2018 at
10:45 11 How to format a document in Notepad++

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?

1 How to convert multiple repeating rows to


21 Answers Sorted by: Highest score (default) columns and then from columns back to
rows in 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

2819 0 C# XML parsing issue


You may need to install XML Tools using your plugin manager in order to get this option in
your menu. See more linked questions

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?

1231 Convert tabs to spaces in Notepad++


668 if you cant find XML Tools under Plugins, intall it from Plugins > Plugins Manager > Show Plugins
Manager – ala Apr 3, 2012 at 1:56 1259 How to reformat JSON in Notepad++?

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

Hot Network Questions


You need to install the XML tool from the Plugins menu item → Plugins Admin... → Plugins
Admin dialog appears and then scroll to bottom of available plugins and check the XML tools, Implicature vs implication

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?

Port-forward from and to WAN?

What is the origin and basis of stare decisis?


Step 1: Install XML Tools plugin
Step 2: Format ....completed How do high current paths work in PCB design?
124 How to calculate the integral only in real domain?

Geometric properties of the adjoint action of a


reductive group

Join list to dataframe in R

Justifying why a nanoassembler can only produce


inorganic things

How to determine the unique combination of


digits satisfying a given relation?

Is this constraint with an indicator function


nonlinear?

Who runs the Russian-controlled Donetsk and


Luhansk at a regional level nowadays?

When and/or how did Western music shift from


downward to upward scale concepts?

How can I get Zelle to refund my buyer?

Windows 10 Task Manager's border lines are


absent on the right / bottom

Did Gollum want possession of the Ring but not


want to wear it?

Is "I'll call you at my convenience" rude when


comparing to "I'll call you when I am available"?

Are FAA Written Exam Questions 'Dynamically'


Selected?

What is the limit to how much humanity can


advance in the physical sciences?

Mathematical Platonism. Are numbers real?

Does the effect of Fireball negate the spikes of


Spike Growth?

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

Try TextFX → TextFX Html Tidy → Tidy: reindent XML

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

Show 2 more comments

Plugins -> XML Tools -> Pretty Print (libXML) or Ctrl + Alt + Shift + B

38
You probably need to install the plugin:

Plugins > Plugins Manager > Show Plugins Manager

If you are behind a proxy, download it from here.

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)

Enable 'text auto update' in plugin manager-> UniversalIndentGUI


Shortkey = CTRL + ALT + SHIFT + J

TextFX
(this is the tool that most of the users use)

Shortkey = CTRL + ALT + SHIFT + B

XML Tools
(customized plugin for XML)

Shortkey = CTRL + ALT + SHIFT + B

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.

2. XML Tools -> Pretty print (Text indent)

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

OK, here is how I did it in Notepad++:

11 Plugins
Plugin manager
Show plugin manager

Check XML tools

Install
Restart Notepad++

Open XML file


Plugins

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

If you get this error:

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.

Share Improve this answer Follow answered Jun 1, 2017 at 13:00


ᗩИᎠЯƎᗩ
2,113 5 28 41

Add a comment

Plugins -> Plugins Admin -> search for XML Tools

9 Once install the XML Tools Plugin

select the entire XML file content and click on pretty print

or

Ctrl + Alt + Shift + B

Share Improve this answer Follow answered Nov 9, 2021 at 17:08


Lova Chittumuri
2,732 1 27 29

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)

6 Installing the XML Tools

If you run Notepad++ and look in the Plugins menu, you’ll see that the XML Tools aren’t
there:

1. Download the XML tools from here.

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.

5 I am currently using Notepad++ v7.8.6

New location is:

Plugins tab
Plugins Admin...

Plugins Admin dialog appears with Available plugins tab as the default

Scroll to the bottom and check the XML Tools checkbox


Click Install button in top right of the dialog

This will close Notepad++ while it installs and then restart it automatically.

Then there are a couple keyboard shortcuts to beautify the XML:

Pretty Print: Ctrl + Shift + Alt + B

Pretty Print (indent attributes): Ctrl + Shift + Alt + A

To see more XML Tools options:

Plugins tab

XML Tools option

Share Improve this answer Follow answered Jun 24, 2020 at 5:24
SandstormNick
1,501 14 23

Add a comment

"But can Notepad++ do it?"

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:

1. Paste the XML content in the input window

2. Click the "Beautify / Format" button

3. Copy formatted XML output from the result window


4. Paste in Notepad++

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.

UniversalIndentGUI formatted some lines like this:

<ClockStatus>1
</ClockStatus>

And I would have preferred:

<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++

code-formatting or ask your own question.

STACK OVERFLOW PRODUCTS COMPANY STACK EXCHANGE NETWORK Blog Facebook Twitter LinkedIn Instagram

Questions Teams About Technology


Help Advertising Press Culture & recreation
Collectives Work Here Life & arts
Talent Legal Science
Privacy Policy Professional
Terms of Service Business
Contact Us
API
Cookie Settings
Data Site design / logo © 2023 Stack Exchange Inc; user
Cookie Policy contributions licensed under CC BY-SA. rev 2023.1.14.43159

You might also like