With Firefox, you can change browser settings with the Browser Console:

Services.prefs.setInfPref('browser.startup.page', 3);

Note that this does not work with the Web Console:

> Services
ReferenceError: Services is not defined [Learn More]

Does Chrome/Chromium have a similar way to programmatically set preferences?


Well, I use Ubuntu GNU/Linux, and Chromium as my primary browser, and never tried Chrome in Linux. So, for Chromium in Linux I have an answer and I think It should be same for Chrome too. Apparently you can refer this link for Windows Platform.

So, Default Preferences for Chromium Browser in Linux are saved in (See this)


It is much similar to prefs.js file for customizing Default Preferences in Mozilla Firefox but don't know whether It's a .js file or not.

Anyways the Preferences file looks like this. It looks a kind of messy, So, I thought to indent it to make some sense. To view Formmated file Click here. It stores the each preference in the comma separated values where each preference is written in form of JSON Markup

" Preference name " : " value "

Apart from this, in the same folder, there is also a file named "Secure Preferences" that stores only one preference.

As far as programming the preferences are concerned, Chromium Project Page specifies the differences between the Ploicies & Preferences, and also suggests to write ploicies instead of preferences beacuse Policies take precedence to preferences. If "homepage" is specified in both the policies, and in the "master_preferences" file, policies will always override.

You can edit Preferences for the Browser as stated in these pages :

The Chromium Project Page :: Configuring Other Preferences : Under the Section Preferences vs. Policies - 3rd bullet point under Preferences.

The Chromium Project Page :: Preferences : Under the Section Introduction - 6th line. Also this particular page explains pretty much everything you need to do to set preferences programmatically. I am sure that will work for you.

For just a little Reference, See this post by sputnam, in which he shows a sample of Preferences Code edited by him.

|improve this answer|||||
  • @StevenPenny Updated my answer to address your Comment.Also, Chromium Project Page states nothing about Secure Preferences. Maybe we don't need that one to edit. I think editing the Preferences file would do. – C0deDaedalus Dec 14 '17 at 16:34
  • you comment is not valid because the important restore_on_startup setting is stored in "Secure Preferences", and your edit is not valid because current Chromium wont read any secure preferences from master_preferences file, if any at all – Steven Penny Dec 15 '17 at 1:33
  • Thanks for pointing it, I should do some more research. – C0deDaedalus Dec 15 '17 at 7:21
  • If Chrome is running while you edit this file, then I think it will be overwritten – Elliott B May 4 '18 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.