Handle SQL formatting

Last modified: June 23, 2025

dbForge Studio for MySQL can help you format statements in a SQL document, paying attention to case, line breaks, whitespaces, indenting, wrapping, etc., by following the rules of the current formatting profile. All this will make your code readable, clean, and consistent.

Format code

You can format all code in an entire document or its fragment.

Format the whole document

To format the whole document, do one of the following:

  • On the Text toolbar, select Format Document Format Document.

  • Right-click the SQL code or anywhere in a SQL document and select Format > Format Document.

  • Press Ctrl+K, D.

Note

If the Text toolbar is hidden, open it by navigating to the View menu and selecting Toolbars > Text.

Format the current statement

To format the current statement, do one of the following:

  • On the Text toolbar, select Format Current Statement Format Current Statement.

  • Right-click the SQL code and select Format > Format Current Statement.

  • Press Ctrl+K, S.

Format a code fragment

To format a specific code fragment:

1. Select the code fragment you want to format.

2. Right-click the selected code and select Format > Format Selection. Alternatively, press Ctrl+K, F.

Formatting errors

dbForge Studio can format only complete code blocks and does not format statements with errors. Applying formatting to a code fragment, for example, a part of a query or a single line of code may result in a syntax error. In this case, the tool displays an error notification.

Formatting error

To view the error details, do one of the following:

  • Navigate to the View menu and select Output. Alternatively, press Ctrl+W, O.
  • Navigate to the View menu and select Error List. Alternatively, press Ctrl+W, E.