Customizing Fonts in Firefox

Firefox Customization

This guide will walk you through how to change the fonts used in different parts of the Firefox browser.

Prerequisites

  • You need to have Mozilla Firefox installed on your computer.
  • Familiarity with basic file system navigation (creating folders and files).

Changing the Developer Tools Font

This will change the font used within Firefox’s Developer Tools.

  1. Open Troubleshooting Information: Open Firefox and press the Alt key to show the top menu. Click on Help $\rightarrow$ Troubleshooting Information.

    Firefox Help menu with 'Troubleshooting Information' highlighted
  2. Open Profile Folder: On the Troubleshooting Information page, locate the Profile Folder entry and click the Open Folder button beside it. This will open your Firefox profile directory in your operating system’s file explorer.

    Troubleshooting Information page with the 'Open Folder' button highlighted
  3. Create the chrome Folder: In the profile directory that opens, create a new folder named chrome (all lowercase).

    File explorer showing the creation of the 'chrome' folder
  4. Create userContent.css: Inside the newly created chrome folder, create a new text file and save it with the name userContent.css. You might see a warning about changing the file extension; confirm that you want to do this. More info on userContent.css

  5. Add CSS for Dev Tools: Open the userContent.css file with a text editor and copy the following CSS code into it:

    @import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap");
    
    @-moz-document regexp("chrome://browser/content/devtools/**/.*")
    {
      .devtools-monospace {
        font-family: "JetBrains Mono", monospace !important;
        font-size: 8pt !important;
      }
    }
    
    • @import url(...): This line imports the JetBrains Mono font from Google Fonts.
    • @-moz-document regexp(...): This tells Firefox to apply the styles within this block only to pages whose URL matches the given regular expression, which in this case targets the Firefox Developer Tools.
    • .devtools-monospace: This selector targets the elements within the Dev Tools that use a monospace font.
    • font-family: This sets the font to “JetBrains Mono”, and falls back to a generic monospace font if JetBrains Mono isn’t available.
    • font-size: This sets the font size to 8 points. Feel free to adjust this value.
  6. Enable User Profile Customizations: Open a new tab in Firefox, type about:config in the address bar, and press Enter. You might see a warning; click “Accept the Risk and Continue”. In the search bar, type toolkit.legacyUserProfileCustomizations.stylesheets and set this preference to true by clicking the toggle button.

  7. Restart Firefox: Close and restart Firefox for the changes to take effect.

Customizing Code Block Fonts on Web Pages

This will change the font used in <code> elements on websites you visit.

  1. Edit userContent.css: Open the chrome/userContent.css file you created earlier.

  2. Add CSS for Code Blocks: Add the following CSS code to the end of the file:

    code {
      font-family: "JetBrains Mono", monospace !important;
    }
    
  3. Restart Firefox: Save the userContent.css file and restart Firefox.

Modifying the Global UI Font

This will change the font used for the entire Firefox browser interface (menus, tabs, etc.).

  1. Create userChrome.css: Inside the chrome folder, create a new text file and save it as userChrome.css.

  2. Add CSS for Global UI: Open the userChrome.css file with a text editor and copy the following CSS code into it:

    @import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap");
    
    * {
      font-family: "Inter" !important;
    }
    
  3. Enable User Profile Customizations (if you haven’t already): Go to about:config and ensure that toolkit.legacyUserProfileCustomizations.stylesheets is set to true.

  4. Restart Firefox: Save the userChrome.css file and restart Firefox.

Reverting to Default Fonts

To go back to the default fonts, you can either:

  • Delete the chrome folder inside your profile directory.
  • Remove the CSS code you added from the userContent.css and userChrome.css files.

Finding Other Fonts

You can explore other fonts on websites like Google Fonts. To use a different web font, replace the @import url(...) line with the one provided by Google Fonts for your chosen font. For locally installed fonts, you can directly use their name in the font-family property (e.g., font-family: "Your Local Font Name", sans-serif !important;).