Take help of a web browser and enter in www.icloud.com with the apple id and password used in an iOS device , the contacts that were saved in will be visible select the desired contacts and click on gear icon in the left bottom corner and click on export as v card .
Â
Open finder , click on downloads , right click on .vcf file and open with contacts .app( default ) .
Â
The address book will get opened , a pop up window will appear stating are you sure you want to add number of cards , click on add .
Â
Again open your address book the contacts that were in the iOS will be transferred under the section “ All contacts “ in the Mac address book .
Â
Sign out from www.icloud.com used with Apple ID and password for an iOS device .
Â
Then enter in www.icloud.com with the apple id and password used in the Mac , click on gear icon and click on import as v card all the contacts will be transferred in the iCloud server , click on create group on the bottom right corner an untitled folder will be created in the side bar and the contacts from iOS are all transferred to the iCloud server account .
Â
See some articles iCloud: Export a contact as a vCard from iCloud Contacts
iCloud: Import a contact into iCloud Contacts
iCloud: Create a group in iCloud Contacts
Read these https://support.apple.com/kb/PH2660?locale=en_US
https://support.apple.com/en-us/HT205754