WebStorm 2017.3 Help

Command Line Formatter

Command-line source code formatter is a special functionality within WebStorm that lets you format arbitrary files outside a project.

The script is format.bat/format.sh located in the <WebStorm_HOME>/bin home directory. The script launches WebStorm which formats the specified files and quits:

format [-h] [-r|-R] [-s|-settings settingsPath] [-m|-mask masks] [path1 [path2]...]

You can launch the script with the following options:

-h Shows help and quits.
-r|-R Scans directories specified in path1,path2... recursively.
-s|-settings settingsPath settingsPath is a path to the file with the code style settings. You can use one of the following:
  • A file with exported code style settings: in the Settings/Preferences dialog (Ctrl+Alt+S), open the Editor | Code Style settings page and click Export under EditorConfig.
  • The .idea/codeStyleSettings.xml file stored in your project directory (for WebStorm version 2017.2 and below).
  • The .idea/codeStyles/Project.xml file stored in your project directory (for WebStorm version 2017.3 and above).

If this parameter is omitted, the default code style settings are used.

-m|-mask masks A comma-separated list of file masks which defines the files to be processed. Wildcards * (any string) and ? (any single character) are supported.
pathN The path to a file or directory to be processed.


1. Format all files in C:\Data\src directory including all subdirectories using the default code style settings:

format -r C:\Data\src

2. Non-recursively format all .java and .html files in the C:\Data\src directory using code style settings from C:\Data\settings.xml:

format -s C:\Data\settings.xml -m * .java,*.html C:\Data\src
Last modified: 28 December 2017

See Also