Can you recommend a sql formatter?

Chris Sijtsma 106 Reputation points
2020-11-17T14:17:45.18+00:00

Dear colleagues,

Which SQL formatter would you recommend? In our organization, we have coding standards. My problem is, there are to many of them. As I am responsible for the repositories containing SQL, I want to enforce a single standard by automatically formatting the code in check-in. I would like to have some configuration options to tweak the format to my liking.

Thanks for your help,
Chris

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,492 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,708 questions
{count} votes

Accepted answer
  1. Dirk Hondong 871 Reputation points
    2020-11-17T14:39:24.05+00:00

    If you just want to do it quickly, why not utilize the RedGate Page?
    https://www.red-gate.com/website/sql-formatter

    Otherwise they have the formatter in their tool SQLPrompt as well, but it is not for free.
    Other way to do it:
    Visual Studio Code
    Afaik there's also the option to format code.

    But since you want to establish a standard ( I Really should start reading first all information before answering... :-) )
    it is easier to go for an appropriate tool.

    ApexSQL is another one where you can also define how T-SQL code should look like.

    Regards
    Dirk

    1 person found this answer helpful.
    0 comments No comments

8 additional answers

Sort by: Most helpful
  1. m 4,276 Reputation points
    2020-11-18T02:15:36.603+00:00

    Hi @Chris Sijtsma ,

    Which SQL formatter would you recommend?

    Aggree with @Dirk Hondong and @Tom Phillips .

    ApexSQL Refactor

    Actually, there are many online sql fomatter tools, you can input "sql server formatter" in google and have a reference.
    And this article will guide you through some SQL formatter options via SSMS and using 3rd party SQL formatting tool such is ApexSQL Refactor to format code.

    More information:how-to-format-sql-code-in-sql-server-management-studio

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.


  2. Chris Sijtsma 106 Reputation points
    2020-11-18T07:42:06.513+00:00

    All of you, thank you very much. In the old SQL Forum, multiple posts were allowed as answer. In this forum, you can only select one. I really appreciate all contributions.


  3. Guido Thelen 0 Reputation points
    2023-10-27T13:32:48.83+00:00

    There is another free formatter for most popular Databasese. It is SQLinForm which can be found here: www.sqlinform.com

    0 comments No comments

  4. Don Price 0 Reputation points
    2025-06-12T08:53:11.8266667+00:00

    Hi Chris,

    Besides the already well-known SQL Prompt from Redgate — which is definitely a solid tool — I personally prefer the SQL formatter from dbForge. I find it more flexible and detailed in terms of configuration. It comes with several built-in formatting styles, but more importantly, it allows you to fully customize your own formatting profile, which you can then apply consistently across your projects.

    If you want something quick and lightweight, they offer a free Online SQL Formatter, which is handy for smaller tasks.

    For deeper integration with SSMS, SQL Complete includes a formatter with lots of granular options. You can define specific rules and even share formatting profiles with your team.

    And if you're looking for a full-featured IDE, dbForge Studio for SQL Server includes the same advanced formatter, along with tools for database development, code review, and version control integration — which might be useful for enforcing formatting during check-ins.

    Hope that helps!

    Regards,
    Don

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.