Where iTunes stores my playlists and ratings I am wondering where iTunes keeps all my playlists? Locally on my computer or in the iCloud? I have created the new playlist on my Mac and I can see it on iPhone (without connecting it to MAC), so it looks like it is stored in iCloud. Is it right? Do I need to do something to backup them?

And the similar question about ratings. Where they are stored and how can I keep them between iTunes and Mac OS reinstallation?
Actually it stores the original on your computer.

The iCloud just gets a copy of it if you have set it up that way.

You can find the file in the ~/Music/iTunes/iTunes Library.itl

and in the iTunes Music Library.xml (located in same place)

https://support.apple.com/en-us/HT201610