If you want to connect a new device to network you should know WiFi password. If you have changed the default password and do not remember the new one, do not despair! You can find WiFi password through Macbook your, provided you have connected to this network at least once with this Mac device. In fact, you can find the password with Keychain.

How to find WiFi password on Mac?
The Keychain Access app on MacBooks stores personal data of users And them passwords. It could be considered as well macOS password manager. Each time you save the password access when you link to a site, an account e-mail, a network etc, you can see it in Keychain.
How to view the WiFi password on your Mac:
- Open the Keychain Access App: Go to Spotlight (press Command-Space bar), type “Keychain” and press enter.
- Search for your WiFi network name and open it: Enter the name of the WiFi network in the search bar at the top and double-click it.
- Click “Show password"
- Enter your username and password and press “Enter“: Enter the credentials you use to connect to your Mac
You will now see the WiFi password on your Mac next to the "Show password" option. At this point, you can change your WiFi password if you wish.

How to share WiFi password from Macbook to iPhone?
If you just want to share your WiFi password from your Mac to other macOS devices, iOS and iPadOS, then you do not even need to know the password. Apple offers a feature that allows users to share WiFi password from Mac to iPhone or other devices Apple, without knowing the password.
make sure that your Macbook is already connected to your WiFi network and that The other person's Apple ID is in your Contacts app. Now, bring the device with which you want to share the password (iPhone), close to your Mac and select the WiFi network in it. A notification will appear on your Mac asking you to share your WiFi password. Click on “Common use“. This simple way, you can share the password.
Source: Fossbytes