DevTools Tips

Write code on multiple lines in the Console

If you're feeling adventurous and want to write longer pieces of code in the Console to execute more complex things, it can quickly become difficult.

Thankfully, there are a few ways to make your life easier by writing on multiple lines, like you would in a code editor:

  • Use Shift+Enter to create a new line without executing the expression. This works in all browsers.

  • Or use Firefox's multiline editor. To do this, click on the Switch to multi-line editor mode button located in the top-right corner of the Console message area (or press Ctrl+B).

    Tthe button to switch the Firefox console to the multi-line mode.

  • Or you can create code snippets in Edge, Chrome, or Safari's Sources tools. The added advantage of this technique is that code snippets are saved on your disk, and therefore can be used even after you've restarted the browser. See Re-use scripts as snippets for more information.

    The snippet tab in Edge's Sources panel.