How to examine source code of Firefox extension before installing it?

As Wladimir pointed out the .xpi file is simply a ZIP archive put together in a particular way. Open it with WinRAR, 7-zip or rename it to .zip and open it with your OS's default tool.

EDIT: (It appears that Mozilla's addons page no longer has this type of "Install" button, so this method won't work.) To get ahold of the .xpi file use https://addons.mozilla.org instead of the built-in extension manager. From there you can right-click on the install button and choose Save as...

With installed extensions, you can:

  1. open your Firefox profile folder
  2. double-click the extensions subfolder
  3. identify the .xsi file of the desired extension (some are obvious, others not)
  4. right-click on the .xsi file and choose Open With (and then possibly More Apps)
  5. choose your zip file management app (ie. WinRAR, 7-Zip, etc) and the extension should open as a compressed folder.

To check a Firefox extension source before installing. This works on macos and linux.

  1. Got to e.g. https://addons.mozilla.org/en-US/firefox/addon/open-same-tab/
  2. Right click "+ Add to Firefox" and "Copy Link Location"

Screenshot of Firefox showing "Copy Link Location" menu item

  1. Download and unpack the copied url:
$ curl -L https://addons.mozilla.org/firefox/downloads/file/3570442/open_same_tab-0.1.7-fx.xpi?src=dp-btn-primary > /tmp/extension.xpi
$ unzip /tmp/extension.xpi -d /tmp/extension

The extension source is now in /tmp/extension.

  1. To install if you're happy with the review, open file:///tmp/extension.xpi in Firefox.