Skip to content

Instantly share code, notes, and snippets.

@skwashd
Last active September 12, 2020 18:01
Show Gist options
  • Save skwashd/30c918e43fc741e01077b65bc22c6730 to your computer and use it in GitHub Desktop.
Save skwashd/30c918e43fc741e01077b65bc22c6730 to your computer and use it in GitHub Desktop.
Export stored passwords from Google Chrome to 1Password

This code snippet is for exporting passwords stored in Google Chrome for use in 1Password. It generates a 1Password compatiable CSV file.

NOTE: Your password are exported as plain text. Take proper precautions when storing the file and use a secure deletion tool.

To export your passwords follow these steps:

  • visit chrome://settings-frame/passwords
  • Open the Chrome console (Mac: [Cmd] + [Option] + J / Windows or Linux: [Ctrl] + [Shift] + J`)
  • Paste the code above into the console
  • Enter your password when prompted so your keyring can be unlocked
  • Wait
  • Copy and paste the output to a file ending in .csv
  • Follow the 1Password CSV import guide
  • Let everyone know or buy me a drink to say thanks.

This is a modified version of the code provided by ccpizza to the question How can I export chrome passwords? on superuser. The changes reformat the CSV output so 1Password is happy. I also cleaned up a few things as went.

Licensed under CC-BY-SA-3.0.

var out = [],
pm = PasswordManager.getInstance(),
model = pm.savedPasswordsList_.dataModel,
pl = pm.savedPasswordsList_;
for (var i = 0; i < model.length; i++) {
PasswordManager.requestShowPassword(i);
}
alert("After you press Ok results should appear in ~5 seconds.\n" +
"If password fields are empty, try increasing the timeout in the last line," +
" i.e. set to 10000 for 10 seconds");
setTimeout(
function () {
out.push('"title","url","username","password","notes","tags"');
for (var i = 0; i < model.length; i++) {
var record = model.array_[i],
user = record.username,
proto = record.url.split("://")[0],
item = pl.getListItemByIndex(i);
if (!item) {
// Skip dodgy items.
continue;
}
var pass = item.querySelector("div.password input").value.trim(),
line = `"${record.shownOrigin}","${proto}://${record.shownOrigin}","${user}","${pass}","Submission URL: ${record.url}","from-chrome"`;
out.push(line);
}
document.body.innerText = out.join("\n");
// The line below controls how long the export can run.
}, 5000);
@aneutron
Copy link

I have the same error.

@guruz
Copy link

guruz commented Feb 1, 2018

There is another version at https://gist.github.com/ryanpcmcquen/cee082bff514f8849a29c409fe3571ff that works in chrome 65

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