Windows, try this: https://www.getsharepod.com/
Mac, try this: https://macroplant.com/iexplorer (Could be some free alternatives if you google more!).
If you buy your music on the iTunes Store, you can just plug in your iPhone and go onto iTunes: File > Organise Library > Transfer Purchases (something like this, I'm going off the top of my head). This transfers everything off your iPhone that was bought off iTunes. Alternatively, go to the purchased selection of the iTunes Store and you can redownload everything purchased there for free!