How to dump a MacOS key chain into a text file: (replace login.keychain with the name of the keychain in question).

security dump-keychain -d login.keychain

Or better still pipe it directly into a GPG symmetrically encrypted file. Perfect for backing up your keys and logins if you store them in your key chain!

security dump-keychain -d login.keychain | gpg -c