Your going to need to back them up to an external hard drive or flash drive, and then re-import them when you do a fresh installation.
Step by step?
Get an external drive and plug it in, it will appear on the desktop (provided it's in a Mac recognised format). Go to MacintoshHD>Home>Music>iTunes>iTunes Library, and drag that folder to the external drive. Eject the drive after it has finished copying.
When the new install is done, re-connect the drive and drag that library folder over the iTunes window. It will copy the tunes and create a new library.
Done.
Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.