Skip to content

Instantly share code, notes, and snippets.

@alvesvaren
Last active April 19, 2022 06:50
Show Gist options
  • Save alvesvaren/a5e8d18a164d9a61d6b03ea7690bd3fb to your computer and use it in GitHub Desktop.
Save alvesvaren/a5e8d18a164d9a61d6b03ea7690bd3fb to your computer and use it in GitHub Desktop.
Python 3 script to convert Dashlane csv-export to Bitwarden importable csv

Dashlane web export to bitwarden vault

I have only tested it on linux but it should work on windows+macos too.

To use:

  1. Make sure python 3 is installed
  2. Export the data from dashlane by visiting the web app, then pressing "My account" > "Settings" > "Export Data"
  3. Unzip the .zip-file downloaded from dashlane
  4. Download this script and put it in the same folder as the unzipped dashlane files
  5. Open a terminal in the folder where the csv-file is located
  6. Run python convert.py credentials.csv -o bitwarden.csv
  7. Open the bitwarden web app
  8. Go to "Tools" > "Import data"
  9. Select the format "Bitwarden (csv)"
  10. Select the file bitwarden.csv in the folder of your unzipped dashlane export
  11. Press "Import data"

Note: This script only converts your passwords saved in dashlane, not secure notes, saved payment options or personal information.

#!/usr/bin/python3
from csv import DictReader, DictWriter
import argparse
import io
parser = argparse.ArgumentParser(description="Convert Dashlane csv-export to Bitwarden importable csv")
parser.add_argument("file", type=str, help="Dashlane credentials.csv-file to convert")
parser.add_argument("--output", "-o", type=str, help="Output csv file")
args = parser.parse_args()
new_fields = [
"folder",
"favorite",
"type",
"name",
"notes",
"fields",
"reprompt",
"login_uri",
"login_username",
"login_password",
"login_totp"
]
with io.open(args.file, encoding="utf-8-sig", newline="\n") as file:
data = DictReader(file)
with io.open(args.output, "w", newline="\n") as file_new:
writer = DictWriter(file_new, fieldnames=new_fields)
writer.writeheader()
mapping = {
"username": "login_username",
"title": "name",
"note": "notes",
"category": "folder",
"url": "login_uri",
"password": "login_password",
"otpSecret": "login_totp",
}
for row in data:
new_row = {}
for key, value in row.items():
if key in mapping:
new_row[mapping[key]] = value
if row["username2"] or row["username3"]:
new_row["fields"] = f"username2: {row['username2']}"
if row["username3"]:
new_row["fields"] += f"\nusername3: {row['username3']}"
writer.writerow(new_row)
@jjmoeller
Copy link

Thank you so much. I was interested in ditching Dashlane and this made it very easy.

@Isaac-Balbin
Copy link

Isaac-Balbin commented Apr 19, 2022

I get (on MacOS) using Python 3.8.5

Traceback (most recent call last):
File "convert.py", line 50, in
if row["username2"] or row["username3"]:
KeyError: 'username2'

Is this is only designed to work on the credentials file and not securenotes etc? No matter though because bitwarden imports dashlane csv files anyway ...

@alvesvaren
Copy link
Author

I get (on MacOS) using Python 3.8.5

Traceback (most recent call last): File "convert.py", line 50, in if row["username2"] or row["username3"]: KeyError: 'username2'

Is this is only designed to work on the credentials file and not securenotes etc? No matter though because bitwarden imports dashlane csv files anyway ...

Yes, it only works on credentials. Bitwarden only imports the dashlane csv from the PC client (which has been deprecated and doesn’t work natively on linux etc) and not the web app. This script allows you to convert the .csv file that is downloadable from the web app :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment