Run prettier in WebStorm or IntelliJ on Windows

Eli Segev
2 min readMar 15, 2018

Prettier can format your code, and one can have JetBrains WebStorm or IntelliJ do that from within the IDE.

This guide assumes you installed prettier globally.

Versions older than 2018.1

Go to File> Preferences (WebStorm) or Settings(IntelliJ) > Tools> External Tools.
Click the Plus sign to add a new External Tool.

Plus sign to add External Tool

Fill in the following data:

Name: prettier
Program: C:\Users\<username>\AppData\Roaming\npm\prettier.cmd
Arguments: — write $FilePathRelativeToProjectRoot$
Workin directory: $ProjectFileDir$

Create a new External Tool

Now, to have a key shortcut to run prettier, and still on Preferences/Settings, go to Keymap > External Tools > External Tools > prettier (if it doesn’t appear there, apply changes, close Preferences/Settings and reopen it).
Right-click the External Tool prettier and choose “Add Keyboard Shortcut”.
Choose the key shortcut you prefer and approve all the way to your code. For example: Ctrl + Shift + s

Add Keyboard Shortcut dialog

That’s it. You’re all set to use prettier within WebStorm or IntelliJ on your Windows, with your selected key shortcut.

Version 2018.1 and later

Use the new File Watchers option.

--

--