There are at least 1.980.000 results on google alone, if you search for the phrase “import chrome passwords into firefox”, or “export chrome passwords into firefox”, “export chromium passwords to firefox” or something similar.

Yet, after parsing meticulously through at least 30..40 pages/URL found in the search result pages, and having done that time and time again over the past two or three years, I still couldn’t find a simple, workable solution that would allow virtually anyone to export the passwords from Google Chrome or Chromium browsers, and then, simply import them in firefox.

I’ve seen plenty of the ridiculously proud and disrespectful answers given both by google staffers on the support forums, and mozilla support and community members in both browser families’s fan groups, to understand that it’s simply not a big deal to either of them – chromium/chrome developers on one hand, and mozilla/firefox developers on the other hand – they simply don’t care if their users cannot export passwords from one browser and import them into another.

So, after being faced several times with the dilemma of this stupid incompatibility between the two browsers’s password format, over the past 2 or 3 years, I just had to come up with a better, faster, simple solution to export the passwords from Chromium and import them in Firefox.

The solution described here took about 24 hours to develop, but it shouldn’t take more then a few minutes – 10 minutes or so – to make it work on your own computer, provided you are at least moderately knowledgeable in linux (debian/ubuntu/mint/peppermint) and understand the commands described and programs and syntax used.

The solution presumes the following:

– you know your way around your linux box/console

– your system is based on debian/ubuntu/mint/peppermint or similar debian offshoot

-your system has sqlite3, php and php-cli* installed

– the Chromium/Chrome profile from which you are trying to export the passwords, is your own and the synchronization with the data from the browser’s sync storage has been performed

If you are using Chrome, and not chromium, wherever you see “/chromium” in the scripts below, simply replace it with “/google-chrome” (or whatever the main profile directory of your chrom* browser is) and the scripts should work fine.

First, to make sure the data stored in the local storage, has been synced with the online data from Google’s storage, close your chrome or chromium, and make sure no background processes are allowed to continue after closing the browser. If you have allowed “enable background tasks to run after closing the browser” or something similar, you should have a small chromium or chrome icon in the notification area (that is, if your desktop environment is Gnome, meaning Gnome 2 based, or Mate, or Cinnamon, NOT that joke of a DE gnome 3 or unity, on these latter stupid desktop environments, I have no clue where any notifications even reside, and I don’t want to know). So if you have a notification with the browser’s icon, click on it – or you might have to right-click – and then click “Exit” in the menu that appears. This makes sure that all background processes of the browser are closed.

Wait a few seconds to make sure the necessary commits to the harddisk are made. Then best using ALT+F2 to bring up the “Run application” prompt, enter the following command and press enter:

/usr/bin/chromium-browser %U –password-store=basic

This will load chromium-browser and make a sync of the password data stored online, to your local storage. If you use chrome, replace the “chromium-browser” part with whatever executable name you have for your chrome browser.

Wait a few second, if you can see the HDD activity LED on your pc/laptop, try to determin if the sync is still undergoing by paying attention to that LED, if the sync operation is still on, the LED will blink repeatedly.

After the sync has been performed – just to make sure you don’t damage any data from your online storage – go to your browser’s settings, click on “Signed in as…” and then click on “Disconnect your google account”. Exit the browser again, and make sure there are NO background processes of the browser left.

(You could open the terminal and check with “ps xa | grep chrom” or something similar. )

After all background processes of the browser are closed, I recommend you create a new folder just for this task, in your home folder, for instance “chromepassbackup”.

Change path to your newly created directory in terminal and copy the local storage of your browser to a more easily managable file location with the following command:

cp ~/.config/chromium/Default/Login\ Data ./logins.sqlite

This will create the “logins.sqlite” file, as a copy of your Login Data sqlite database from your chrome profile directory.

Now you need to export the login data from the file, as a simple CSV file. Fortunately, this is very easy to do with sqlite:

sqlite3 -noheader -csv -separator ‘,’ logins.sqlite “SELECT * FROM logins” >logins.txt

This will create the “logins.txt” file in the same directory, with all your login data in CSV format.

In the next step, you need to create the PHP file that will parse the “logins.txt” file LOCALLY, from the terminal ! (hence, you need php-cli* installed), not as a webpage in a browser.

——– parse_me.php———

<?php

#load logins.txt as an array
$lines=file(‘logins.txt’);
#we make sure we only have unique values;
$lines=array_unique($lines);
#create a new file that will hold the passwords in the new, firefox importable format ;
$handle=fopen(“chromium_pass_export.xml”,”w+”);
$passex_header='<xml>’ . “\n” . ‘<entries ext=”Password Exporter” extxmlversion=”1.1″ type=”saved” encrypt=”false”>’ . “\n”;
fwrite($handle,$passex_header);
#we loaded the parsed logins file as an array and now we change the values of the array elements
foreach($lines as $key => $value)
{
#each string_value is a line with ‘,’ splittable !
$array=explode(“,”,$value);
#start “composing the new string and write it to the newformat file ;
$newline='<entry host=”‘;
$thehost = str_replace(“=”,”%3d”,$array[0]) ;
$thehost = str_replace(“&”,”%26″,$thehost);
$newline .= $thehost . ‘”‘;
if(empty($array[3]) || $array[3]=='””‘)
{
$newline .=’ user=””‘ ;
}
else
{
$newline .=’ user=”‘ . str_replace(‘”‘,”,$array[3]) . ‘”‘;
}
if(empty($array[5]) || $array[5]=='””‘)
{
$newline .=’ password=””‘;
}
else
{
$newline .=’ password=”‘ ;
$thepass=str_replace(‘”‘,”,$array[5]) ;
$thepass=str_replace(“%”,”%25″,$thepass);
$thepass=str_replace(“&”,”%26″,$thepass);
$newline .= $thepass . ‘”‘;
}
if(empty($array[1]) || $array[1]=='””‘)
{
$newline .=’ formSubmitURL=””‘;
}
else
{
$newline .=’ formSubmitURL=”‘;
$theurl= str_replace(“=”,”%3d”,$array[1]) ;
$theurl = str_replace(“&”,”%26″,$theurl);
$newline .= $theurl . ‘”‘;
}
$newline .=’ httpRealm=””‘;
if(empty($array[2]) || $array[2]=='””‘)
{
$newline .=’ userFieldName=””‘;
}
else
{
$newline .=’ userFieldName=”‘ . str_replace(‘”‘,”,$array[2]) . ‘”‘;
}
if(empty($array[4]) || $array[4]=='””‘)
{
$newline .=’ passFieldName=”” />’ . “\n” ;
}
else
{
$newline .=’ passFieldName=”‘ . str_replace(‘”‘,”,$array[4]) . ‘” />’ .”\n”;
}
fwrite($handle,$newline);

}
$passex_footer='</entries>’ . “\n” . ‘</xml>’;
fwrite($handle,$passex_footer);
fclose($handle);
?>

—- end parse_me.php—

Now, some notes : in the PHP script above, you MUST respect the single-quote/double quote usage as I’ve used it, because in some places you have to export/modify/work with strings that they themselves contain single quotes/double quotes or URL encode strings, that need to be encapsulated as they are.

The URL encodings are absolutely necessary (for instance, replacing “=” with “%3d”, “&” with “%26”, etc.), because in the end, you’ll want to have an xml file with correctly written syntax that can be imported into firefox’s Password Export plugin.

Save the PHP file, for instance, as “parse_me.php” in the same folder. Then in terminal, simply type

php parse_me.php and press enter.

Depending on how many passwords you have to export, it could take some time (just joking, in my case, with over 400 passwords, it took less then a second 🙂 )

When the prompt returns, you should have a file called “chromium_pass_export.xml” in the same folder. Now start firefox, and if you haven’t alread installed the password importer/exporter plugin, press CTRL+SHIFT+A to load the AddonsManager in firefox, and search for “Password Exporter”, or go directly to the plugin’s page on Mozilla HERE and add that plugin to your firefox.

Image with firefox's import-export button in preferences Restart firefox to load the plugin, go to your preferences, “security” tab, and you should have an “Import/Export passwords” extra button now. Click on that button and in the dialog box that appears, select “Import passwords”. Navigate to the file “chromium_pass_export.xml” and open it via the importer. If the file was constructed properly, your passwords should be now imported into firefox, and a count with the number of the imported passwords should be displayed in the import/export window.

Clickin on the “details” link near the count, a detailed log of any eventual error messages related to the import operation will be displayed.

That’s it, your usernames and passwords, all your login data from Chrome or Chromium, should also be available in Firefox now !

Image with password import button in firefox

 

Obviously, both scripts can be improved, and the work on perfecting it, can be continuous, but for the simple, quick way to have your chrome/chromium passwords exported and then imported into firefox, this is the fastest, most efficient way.

It takes more to read through this article, then to actually make the scripts and then export/import your passwords.

The entire process can be simplified further, if you make a bash script, in the folder you’ve created for this taks, let’s name it “get_chr_pass” with the following content :

cp ~/.config/chromium/Default/Login\ Data ./logins.sqlite
sqlite3 -noheader -csv -separator ‘,’ logins.sqlite “SELECT * FROM logins” >logins.txt
php parse_me.php

Save the file and then make it executable with the command :

chmod +x get_chr_pass

Provided that you’ve also put “parse_me.php” in the same folder, you just have to issue

./get_chr_pass

and you’ll have your exported passwords file in just about a second or so.

In case you want to simply download the 2 files, “get_chr_pass” and “parse_me.php”, here they are:

DON’T FORGET TO RIGHT_CLICK !!! AND SELECT “SAVE LINK AS”, because clicking with the left mouse button won’t send you the files as a download 🙂

get_chr_pass

parse_me.php

I hope this article will help someone 🙂

If you run into difficulties with the scripts or with the import/export process, don’t hesitate to ask, leave a comment via the facebook comment box or the disqus comment box, whichever suits you best, and I’ll do my best to reply and help you if I can.

Please share this article with your friends who might need a quick and easy solution to export/import chrome or chromium passwords into firefox ! Thanks.