I want to beautify the SQL Queries I write.
What free tools exist that allow for SQL query formatting?
SSMS provides a couple of options to format SQL code. Those options are indenting, tab sizing, make all code in upper or lower case, comment/uncomment selected code, etc.
Format SQL Code in SSMS Query Window To use the SSMS add-in component we will have to close and then open SSMS after the install of the add-in. Then open a SSMS query window, highlight the code that needs to be formatted. Then select Format T-SQL Code from the SSMS Tools menu. Here is the code after the formatting.
The SSMS Add-in allows you to set your own hotkey (default is Ctrl - K , Ctrl - F , to match Visual Studio), and formats the entire script or just the code you have selected/highlighted, if any. Output formatting is customizable.
Format and Beautify your SQL Statements with ALT+F. You can switch-on the live formatting feature in the SQLinForm Options Dialog. While playing around with the options you can switch on the live preview feature to see immediately the impact of the new formatting style in your SQL.
PoorMansTSqlFormatter is a free and open-source online beautifier, with offline SSMS Add-In, command-line beautifier tool, and Notepad++ plugin.
The project aims to format any T-SQL (2000 or later) script, no matter the length or complexity.
Hope this helps!
As of 10.02.2022 the site is not reachable anymore.
T-SQL Tidy (dead link: http://www.tsqltidy.com) is a very good online SQL formatter/beautifier.
It has a lot of formatting options. Although it's targeted to T-SQL, it should work with most SQL dialects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With