how to change the user agent string in mozilla firefox

User Agent String is a string value associated with a web browser that specifies its browser type, version, Operating system (OS) version and other relevant information and you can change user agent string as needed on your browser. This information is send to the web server when the web browser makes a request for a page or content.

This information is extremely useful to the server, as it allows to serve or send back content in the most suitable format for the machine and browser you are using. The most recognizable use of this information is when mobile smart phones like iPhone and Android can be served a different layout or a mobile friendly website than a desktop. Thus a web browser running on a desktop or tablet will see an entirely different site or content laid out differently than the mobile version.

Examples of user agent strings

By changing the user agent string, you are effectively spoofing or tricking the server into believing that you are using an entirely different web browser in a different operating system. Usually there is no need for this value to be tweaked as most "well designed" websites will cater all the web browsers correctly. Still, there may be conditions and various reasons as to why you want to do this

Using Addons

For Mozilla Firefox, there are several add-ons available that will easily allow you to change user agent string on the fly. Some of the popular ones are

UAControl : A highly rated plugin which is pretty simple to use. It provides the ability to specify user agent strings on a per-domain basis.

User Agent Switcher: Another simple addon that allows you to change the user agent quickly using either a menu item and/or a toolbar button.

User Agent Overrider : This addon allows you to change the user agent string from a toolbar button. This however does not have support for domains, hence will update it globally.

You can find even more plugins by doing a search in Firefox add-ons site. Most of the addons provide very similar functionality, so go with one with good rating and works best with your version of Firefox.

Using Config

Firefox provides an config option to change user agent string. Changing the string through configuration with the steps mentioned below will change the user agent of the browser quasi-permanently unless you change it back. This will be the user agent used across all web domains. So, this usually not a desirable thing to do unless you have a very strong reason for it.

If you like to use custom user agents for only certain web domains then you might be better of using one of the addons mentioned above or refer to the section immediately below this.

It is not easy to get to change the configuration, as there is no good user interface to do this. You can access this config property from within the config editor in Firefox. Follow the steps below to modify using the config editor.

  1. Type the URL about:config in the URL location bar.
  2. Type general.useragent.override in the search bar at the top of the page to filter the entries
  3. Create a new entry if you cannot find one.
  4. Right click anywhere inside the panel and select New -> String
  5. Type in general.useragent.override as the name and click OK
  6. Type in the desired user agent string as the value in the next popup and Click OK
  7. If the property already exists, then double click on the value field and enter the desired user agent in the popup and click OK
  8. Test the user agent string using your preferred method. (Some mentioned below)

Using Config per Domain

You can use the same method described in the section above to change user agent string on a per-domain basis. In order to change the user agent for an example domain named mywebsite.com, follow the steps below…

  1. Type URL about:config in the URL location bar
  2. Type general.useragent.site_specific_overrides in the search at the top to filter the entries
  3. Set or ensure that the value of this property is true
  4. Right click anywhere in the panel and select New->/String/
  5. Type in general.useragent.override.mywebsite.com as the name and click OK (substitute the actual domain you need in the name)
  6. Type in the desired user agent string as the value and click OK
  7. Test the user agent string

You can have as many config properties as needed. Remember to substitute the correct domain name in each of the property name. The generic property name is general.useragent.override.[domian name].

If for some reason you cannot or don't want to use the about:config editor, then you can specify these values in either the pref.js or user_pref.js files. You should be able to find these files inside your firefox profile folder.

Be sure to close and shutdown the Firefox browser first.

  1. Close the Firefox browser
  2. Using a file browser or command line, find the file named pref.js (or user_pref.js) inside the Firefox profile folder.
  3. Open the file in a text editor
  4. Insert the code user_pref("general.useragent.override","Some user agent string"); into the file
  5. Save the file
  6. Restart Firefox

Check the changed User Agent

Once you have set or modified the user agent in the browser, you might want to make sure that this has been set correctly. This is only important if you have set the user agent globally using the config or have it set across all domains. If you just changed it for just one or two specific web domains, then there is really no good to test for it.

There are several websites that will sniff out your user agent string and print it out for you. These are a couple of them that I find useful What is My User Agent and User Agent String.

Whatever the reason for changing the user agent  string, you may want to it remember the fact that you did change it and that it is not set to the default. Otherwise, you might be troubleshooting for a long time when some website functionality does not work correctly which might otherwise have worked with the default user agent. Use this sparingly …