I’ve been using KeePass for my password management needs since early 2014, but I recently decided that I wanted to move to something a bit more substantial. KeePass is an excellent (open source!) piece of software, but since it stores passwords in a single database file the only way that I could really sync it between multiple computers and my phone was to store that file… in Dropbox.
Yeah, as you can imagine that’s not a great solution.
Anyway, I wanted to move over to 1Password but when I tried searching for “Migrate KeePass to 1Password” I kept seeing references to 3rd party scripts I’d need to use to convert my exported data (no thanks) or that it would require a bunch of manual data entry. After giving it a go though, I can tell you it was actually ridiculously easy and straightforward and didn’t require any external tools or scripts! As such, I decided to put together this step-by-step tutorial for migrating your data from KeePass to 1Password!
- Back up your KeePass file
Your passwords are important and whenever you’re doing something like this, first start with a backup! Get a copy of your kdbx file and keep it somewhere safe just in case you run into any problems further in the process.
- Clear out old entries that you won’t want later
Now that you have a backup, rather than spending time exporting old entries only to delete them later I definitely recommend cleaning them up in KeePass at this step.
Export from KeePass
- Open KeePass and the password file you want to export
- Click “File” -> “Export…”
- Select “KeePass CSV (1.x) as the format
- Set “Export to” to the location you want the file saved (use the file selection dialogue by clicking on the floppy disk icon)
- Click “OK”
Import into 1Password
- Open the the 1Password web interface. I’m not entirely sure why this can’t be done in the desktop application (which only seems to support importing a 1PIF (1Password Interchange Format) file, an Agile Keychain or an OPVault folder), so make sure you open the website!
- Click on your profile name in the top right and select “Import”
- Choose “KeePassX” (or “Other”, they actually lead to the same page with the same steps and the same issues)
- Under “Choose a vault”, select the vault you want to import your data into (in this case, “Test”)
- Drag and drop the CSV file from the location you chose in step 4 into the window, or use the file selection dialogue
- Make sure that the data looks reasonable, like checking that there aren’t multiple elements on one line and that your passwords look as expected; the KeePass export escapes quotes (such as changing a password of
abc\"123) which may cause issues. Pay particular note if you see the “Review your items carefully” notification, which may indicate a problem in the import! Details on how to resolve these issues can be found in the Fixing Data Import Issues section
- Change the top line from “Login” to “Ignore Row” (this is the automatically included header line exported from KeePass that 1Password would otherwise try and import as a separate item)
- Click “Continue”
- Set the labels for each data item. By default my version of KeePass exported the data in the following order, but look at what makes sense for your data:
- Click “Import”
- Click “Show imported items”
Your data should now be imported! There are a few things that are worth doing before you consider the process complete though:
- As the final step in the import process says, this is a good time to permanently delete the unencrypted CSV file that you generated!
- Save a final copy of your KeePass kdbx file in a safe location. Although you’ve imported all of your logins into 1Password, you won’t have access to any of the password histories that were stored in KeePass. It’s best to keep a copy available just in the (hopefully unlikely) situation that you need an older password or want to see what changed on that entry over time.
- If you had to clean up any of the data in the original CSV file (using the steps in the “Fixing Import Data Issues” section), now is a good time to fix any badly quoted text or escaped quotations. Go through any of the items that you modified and fix the notes!
And now you’re done. Enjoy 1Password!
Fixing Data Import Issues
The CSV export from KeePass escapes quotation marks (converting
\") and the 1Password import process doesn’t always handle this very nicely. This presents itself in a couple of ways:
One of the scarier issues you might run into is finding that your passwords appear to be wrong when logging into services using the details stored in 1Password. This most likely points to a situation where your original password contained a quote (for example
abc"123) which was then escaped by the KeePass export process (converting the above example to
abc\"123), leading to issues logging in since the password is no longer correct.
The fastest way to resolve if you have already started using 1Password or the number of affected items is low is to update any failing entries in 1Password itself by checking the password text and switching any instance of
" (removing the backslash).
If you’ve only just migrated to 1Password or believe that this issue might affect a large number of different entries you can fix the initial data set and re-do the import. This will require going through the CSV file exported from KeePass and manually updating any passwords similar to above, switching any instance of
" (NOTE: Don’t use find and replace! This could inadvertently break situations where quotes have correctly been escaped such as in notes).
Multiple Entries on One Line in Import Data Preview
You may see instances of multiple logins appearing on one line during step 6 of the import process (the import data preview).
In this particular case, the issue was related to the Comments field I was using in KeePass to test the export process:
This is an example of a longer comment with more detail. I'm going to keep writing things and show that they are all migrated automatically without issue. I can even use newlines without a problem since they're persisted across! "I can use quotes as well since they are correctly escaped"
Yes, the hubris of writing that and then finding out it didn’t work properly was not lost on me.
In the exported CSV, KeePass generates the following:
"Service1","Username1","Password1","","This is an example of a longer comment with more detail. I'm going to keep writing things and show that they are all migrated automatically without issue. I can even use newlines without a problem since they're persisted across! \"I can use quotes as well since they are correctly escaped\"" "Service2","Username2","Password2","",""
I’m not entirely sure why, but it seems that 1Password has issues with the escaped quotes near the end of line 6 and considers the following line (line 7) as additional elements to the same login. You can see the problem a bit clearer in the import data preview:
Thankfully, this can be fixed by removing the final quote on line 6 so that the data looks as follows:
"Service1","Username1","Password1","","This is an example of a longer comment with more detail. I'm going to keep writing things and show that they are all migrated automatically without issue. I can even use newlines without a problem since they're persisted across! \"I can use quotes as well since they are correctly escaped\" "Service2","Username2","Password2","",""
Your exact mileage may vary with this approach, but hopefully it’ll point you in the right direction for resolving this issue!