When you log in to websites, applications, and wireless networks on your Mac, you can choose to save usernames and passwords to an integrated password management system called Apple Keychain. It protects the login details using robust encryption and lets you seamlessly auto-fill passwords in subsequent sign-in attempts. But despite the security and convenience, you will run into instances that require you to back up keychain items. 

Whether that’s to transfer the login details to a third-party password manager or to protect them against hardware failure or data corruption, this tutorial will show you several methods to export or back up Keychain passwords on Mac.

Table of Contents

    Sync Passwords Online Using iCloud Keychain

    If you use an Apple ID on your Mac, you can activate a feature called iCloud Keychain to create a cloud-based copy of your passwords on the Apple servers. You can also use it to sync them across devices within the Apple ecosystem (such as the iPhone and iPad). But most importantly, it helps you restore your login info if you reinstall macOS, switch to a new Mac, or reset your Mac’s admin password

    However, iCloud Keychain is not a perfect form of backup. For example, if you accidentally modify or remove a password on your Mac, you can’t get it back. Worse yet, iCloud will also sync your changes to the rest of your Apple devices. But the advantages of using iCloud Keychain outweigh the cons, so it’s still a good idea to have it active on your Mac.

    1. Open the System Preferences app on your Mac.

    2. Select Apple ID.

    Note: If you’ve yet to sign in to your Mac with an Apple ID, use the Sign in with Apple ID option instead and enter your Apple ID credentials.

    3. Check the box next to Keychain.

    4. Enter your Apple ID password and select OK.

    5. Enter your Mac user account password and select OK. That should prompt your Mac to upload your passwords to the Apple servers.

    Note: To get your passwords to show up on another Mac, simply sign in with your Apple ID and follow the steps above to activate iCloud Keychain. On iOS and iPadOS devices, go to Settings > Apple ID > Keychain and turn on the switch next to iCloud Keychain to sync your login info.

    Export Passwords Using Safari Passwords Manager

    Although your Mac comes with a dedicated Apple Keychain manager called Keychain Access, you can’t use it to back up or export items. But if your Mac runs macOS Monterey or later, you can use Safari’s built-in Passwords manager (which lets you view and autofill saved passwords stored on your default login keychain) to save your login info in the CSV file format

    You can then use the CSV file to import the passwords into an alternative password management utility (1Password, LastPass, and Dashlane are among the best password managers for the Mac) or a third-party browser such as Google Chrome or Mozilla Firefox. Or, you can keep it as a backup and re-add the login details to your default keychain if you lose it.

    Warning: The plain-text CSV file that Safari generates will have no encryption, so anyone can be open and view its contents. Make sure to delete the file after importing it to another password manager or store it in a secure location.

    1. Open Safari and select Safari > Preferences on the menu bar.

    2. Switch to the Passwords tab. Then, enter your Mac’s admin password or authenticate yourself using Touch ID.

    3. Select the More icon (three dots) at the bottom-left corner of the Passwords window and pick the Export Passwords option.

    4. Select Export Passwords again on the confirmation pop-up.

    5. Specify a save destination for the CSV file and select Save.

    Note: If you want to re-import the passwords to Keychain (into the same or a different Mac), select More > Import Passwords in the Passwords manager in Safari and select the CSV file.

    Take Manual Backups of the Keychains Folder

    If you open the Keychain Access app on your Mac (go to Launchpad and select Other > Keychain Access), you’ll notice two listings under Default KeychainsLogin and Local Items/iCloud. These keychains store your website, app, and Wi-Fi passwords by default. Additionally, you’ll find user-generated keychains under Custom Keychains.

    Apple Keychain stores all these keychains as separate database files in a folder called Keychains under the Library directory of your Mac user account. You can choose to make periodic backups of the folder and restore the files if you want to revert any accidental changes to your keychain items.

    Note: The best alternative to taking manual backups is to activate Time Machine on your Mac. Not only does it then back up your entire Mac periodically (including the entire Keychains folder), but it also helps you conveniently restore files and folders. Learn how to set up and use Time Machine on your Mac.

    1. Control-click the Finder icon on the Dock and select Go > Go to Folder.

    2. Type in the following and press Enter:

    ~/Library

    3. Copy the Keychains folder to a different directory or an external drive.

    If you make any accidental changes to your keychains, you can restore them by replacing the following database files with your backups:

    Login: Replace the login-keychain-db file.

    Local Items/iCloud: Replace the keychain-2.db, keychain-2.db-wal, and keychain-2.db-shm files under the UDiD (unique device identifier) sub-folder.

    Custom keychain: Identify and replace the custom keychain by filename.

    Note: Custom keychains aside, copying the Login or the Local Items/iCloud database files to another Mac will not work.

    Protect Your Keychain Passwords

    Activating iCloud Keychain or exporting passwords to CSV is quick and convenient. But If you want to create full backups of your keychains, set up Time Machine or make manual copies of the Keychains folder.