Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

How do I export "saved logons"?

  • 3 replies
  • 1 has this problem
  • 481 views
  • Last reply by cor-el

more options

Between two Win10 Home PCs, both used to have all my Saved Logons, but somehow one PC has dropped them all. Both PCs do use Firefox Sync between successfully, but while that synchronizes Bookmarks (& whatever else), evidently NOT "Saved Logons". So, isn't there some way to EXPORT all of them to a file, to then IMPORT them to my other PC? Incidentally, within Saved Logons, there is a button named IMPORT, but it's used is only for importing from 3 other designated browsers, and apparently on the self-same PC. Searching Firefox Support was a waste of time ... their 'results' are just wide nets of hundreds of irrelevant things, no matter how precise I attempt each search. Bad support job on self-help, Mozilla.

Between two Win10 Home PCs, both used to have all my Saved Logons, but somehow one PC has dropped them all. Both PCs do use Firefox Sync between successfully, but while that synchronizes Bookmarks (& whatever else), evidently NOT "Saved Logons". So, isn't there some way to EXPORT all of them to a file, to then IMPORT them to my other PC? Incidentally, within Saved Logons, there is a button named IMPORT, but it's used is only for importing from 3 other designated browsers, and apparently on the self-same PC. Searching Firefox Support was a waste of time ... their 'results' are just wide nets of hundreds of irrelevant things, no matter how precise I attempt each search. Bad support job on self-help, Mozilla.

Chosen solution

https://www.ghacks.net/2018/07/18/how-to-export-firefox-passwords-in-firefox-57/ ++++++++++++++++++++++++++++++++++++ http://www.nirsoft.net/utils/passwordfox.html (Win) PasswordFox v1.58 - Extract the usernames/passwords stored in Firefox Copyright (c) 2008 - 2017 Nir Sofer

Note: Some anti-virus show false positive. ++++++++++++++++++++++++++++++++++ Easily export your passwords from Firefox. https://github.com/kspearrin/ff-password-exporter

Export your passwords from Firefox in a portable CSV or JSON format. It works on Windows, macOS, and Linux. +++++++++++++++++++++++++++++++++++ 3 Tools to Decrypt and Recover Passwords Saved in Firefox • Raymond CC https://www.raymond.cc/blog/how-to-find-hidden-passwords-in-firefox/ +++++++++++++++++++++++++++++++++++ https://www.ghacks.net/2018/07/18/how-to-export-firefox-passwords-in-firefox-57/ ++++++++++++++++++++++++++++++++++++ https://github.com/kspearrin/ff-password-exporter

Read this answer in context 👍 1

All Replies (3)

more options

Actually, there is no feature to export/import saved logins, so the fact that you didn't find an answer has a good basis.

Sync should work if logins are a selected category. However, before changing any Sync settings, I suggest making a backup of your profile, where Firefox stores your browser data. I'll give a link to an article on that further below.

One option to transfer your saved logins would be to copy a pair (or trio) of files from one PC to the other. Those files are:

  • logins.json
  • key4.db
  • key3.db (legacy file, may not be needed)

Those files are stored in your currently active Firefox profile folder. These articles describe how to find that folder and what it contains. On the receiving Firefox, you'll want to exit out before replacing in-use files.

References:

more options

Chosen Solution

https://www.ghacks.net/2018/07/18/how-to-export-firefox-passwords-in-firefox-57/ ++++++++++++++++++++++++++++++++++++ http://www.nirsoft.net/utils/passwordfox.html (Win) PasswordFox v1.58 - Extract the usernames/passwords stored in Firefox Copyright (c) 2008 - 2017 Nir Sofer

Note: Some anti-virus show false positive. ++++++++++++++++++++++++++++++++++ Easily export your passwords from Firefox. https://github.com/kspearrin/ff-password-exporter

Export your passwords from Firefox in a portable CSV or JSON format. It works on Windows, macOS, and Linux. +++++++++++++++++++++++++++++++++++ 3 Tools to Decrypt and Recover Passwords Saved in Firefox • Raymond CC https://www.raymond.cc/blog/how-to-find-hidden-passwords-in-firefox/ +++++++++++++++++++++++++++++++++++ https://www.ghacks.net/2018/07/18/how-to-export-firefox-passwords-in-firefox-57/ ++++++++++++++++++++++++++++++++++++ https://github.com/kspearrin/ff-password-exporter

more options

Note that in Firefox 67-69 you can possibly use the Firefox Lockwise (formerly named Lockbox) extension to share passwords via a Firefox Sync account (2.2.0 is for 67+, older 2.1.0 for 63+).

Note that in Firefox 70 and later Lockwise is a builtin component and can also be used to add a new username and password.


Note that you can use code in the Browser Console to export and import passwords.

See these replies for possible alternatives using the Browser Console to run JavaScript code.


Code for Firefox 52+:

/* EXPORT to firefox-logins.json - Firefox 52 and later */

async function exportLogins (aPath, bytes){
 await OS.File.writeAtomic(aPath, bytes);
}

var tokendb = Cc["@mozilla.org/security/pk11tokendb;1"].createInstance(Ci.nsIPK11TokenDB);
var token = tokendb.getInternalKeyToken();

try {token.login(true)} catch(e) {Cu.reportError(e)}

if (!token.needsLogin() || token.isLoggedIn()) {
 var logins = Services.logins.getAllLogins({});
 var json = JSON.stringify(logins, null, 1);

 var ps = Services.prompt;
 var txt = 'Logins: ' + logins.length;
 var obj = new Object; obj.value = json;

 if (ps.prompt(null, 'Logins - JSON', txt, obj, null, {})){
 var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
 fp.init(window,"",Ci.nsIFilePicker.modeSave);
 fp.defaultString = "firefox-logins.json";

 fp.open((rv) => {
 if (rv == Ci.nsIFilePicker.returnOK || rv == Ci.nsIFilePicker.returnReplace) {
 let bytes = new TextEncoder().encode(json);
 exportLogins(fp.file.path, bytes);
 }})
} else {console.log("<canceled>");} }

/* IMPORT from JSON file - Firefox 52 and later */

async function importLogins(aPath){ /*[52+]*/
let bytes = await OS.File.read(aPath);
let logins = JSON.parse(new TextDecoder().decode(bytes));
ImportLogins(logins);
}

function ImportLogins (logins){ /*[42+]*/
try { /*[60+]*/
 var i,lg;
 for (i=0; lg=logins[i]; i++){if (!lg.origin){lg.origin = lg.hostname}}
 ChromeUtils.import("resource://gre/modules/LoginHelper.jsm");
 LoginHelper.maybeImportLogins(logins);
} catch(e) {/*[42-59]*/
 var i;
 Cu.import("resource://gre/modules/LoginHelper.jsm");
 for (i in logins) LoginHelper.maybeImportLogin(logins[i]);
}
}

var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);

fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter(".json JSON Files","*.json");

fp.open((aResult) => {
  if (aResult == Ci.nsIFilePicker.returnOK) {
  if (fp.file.exists() && fp.file.isFile() && fp.file.isReadable()) {
    var loginsfile = fp.file.path;
    try {
     importLogins(loginsfile);
     console.log("<async import>");
    }
    catch (err) {console.log(err);}
  }
  } else {console.log("<canceled>");}
})

Modified by cor-el