How to run JavaScript in Firefox URL bar?

Solution 1:

Firefox 89 and later

  1. Select Settings menu (3 horizontal lines icon in the upper right corner) More Tools -> Web Developer Tools -> Console tab.

  2. Type JavaScript code after the web console prompt » and press Enter.

The web console prompt will be located in the bottom left corner of the console pane if the console already has output in it.

Firefox 72 and later

Scratchpad is deprecated as of Firefox 70 (bug 1565380), and has been removed in Firefox 72 and later.

  1. Select Settings menu (3 horizontal lines icon in the upper right corner) -> Web Developer -> Web Console.

  2. Type JavaScript code after the web console prompt » and press Enter.

Firefox 57-71

  1. Select Settings menu (3 horizontal lines icon in the upper right corner) -> Web Developer -> Scratchpad.

  2. Click the Run button on the Scratchpad toolbar to run your JavaScript code.


Firefox 56 and earlier

  1. Open a new tab in Firefox and in the URL bar, and enter about:blank to display a blank tab so that you can see what you are doing.

  2. From the Firefox menu select Tools -> Web Developer -> Web Console.

  3. A new Web Console window will open. From the Web Console window click the JS button on the toolbar.

  4. From the Web Console window click on the Scratchpad icon in the toolbar. The Scratchpad icon looks like a notepad.

  5. A new Scratchpad window will open. Copy your javascript code: javascript:alert('Hello, World') in the Scratchpad window.

  6. Click the Run button on the Scratchpad toolbar to run your JavaScript code.

Solution 2:

For firefox android version, you can try this bookmarklet:

javascript:var a=prompt();var f=Function(a);f();

It will open a prompt box. Type your command in it (without "javascript:") and it will run.