How to format files and folders

Last modified: July 9, 2025

dbForge Studio for SQL Server provides the SQL Formatter that enables you to format SQL code efficiently. It also supports bulk formatting that allows you to format multiple selected files or entire directories at once.

Prerequisites

The following file will be formatted:

SQL Formatter - unformatted file

Format files

1. Open the SQL Formatter by navigating to the Tools menu and selecting SQL Formatter.

2. On the Formatting mode page of the wizard, the Files mode is selected by default. To proceed, select Next.

Formatting mode: Files

3. On the File list page, select Add to the select the files you want to format.

  • In the Open window, select the file and then select Open.
  • When the Keep modified files open after formatting checkbox is selected (default option), the formatted files will be opened in the Studio after the formatting process is completed. Otherwise, clear the checkbox.

Tip

To remove the selected file from the list, select Remove.

Files formatting mode - Files list

4. To start formatting the file, select Format.

5. In the Connect to Server window that opens, select the connection and then select Connect.

6. In the pop-up window informating that the number of files have been formmated, select OK to close it.

Files formatting progress

7. If you’ve selected the Keep modified files open after formatting checkbox, the formatted files will open in a new SQL document after the formatting process is completed.

SQL Formatter - formatted file

Format folders

1. Open the SQL Formatter by navigating to the Tools menu and selecting SQL Formatter.

2. On the Formatting mode page of the wizard, select the Directories mode and then select Next.

Formatting mode: Directories

3. On the Folder list page, select Add to the select the folder with the files you want to format:

  • In the Browse For Folder window, select the folder with the file you want to format and then select OK.
  • In the Look at these file types: box, select .sql to format only .sql files or . to apply SQL formatting to all files, regardless of their name or extension.
  • When the Keep modified files open after formatting checkbox is selected (default option), the formatted files will be opened in the Studio after the formatting process is completed. Otherwise, clear the checkbox.
  • When the Include sub-folders checbox is selected (default option), all subfolders within the main folder are also included in the operation automatically.

Tip

To remove the selected folder, select Remove.

Directories formatting mode - Folder list

4. To start formatting the folder, select Format.

5. In the Connect to Server window that opens, select the connection and then select Connect.

6. In the pop-up window informating that the number of files have been formmated, select OK to close it.

7. If you’ve selected the Keep modified files open after formatting checkbox, the formatted files will open in a new SQL document after the formatting process is completed.

Note

Each formatted file opens in a new SQL document.

Save the formatted file

To save the formatted file, on the SQL toolbar, select Save As and save the file to the desired folder.