Best SQL Query Format Tools Online

  • Post author:
  • Post last modified:July 22, 2019
  • Post category:General
  • Reading time:5 mins read

Who does not like formatted SQL codes? They are easy to read, understand and follow the complex logic. Sometimes, when you export SQL code from the database, the code will become messy and hard to understand. In this article, we will check Best SQL query format tools available for free on the internet. Some of them provide an API so that you can integrate in your application.

Best SQL Query Format Tools

Before jumping on the tools introduction. let us understand why the SQL code formatting is important?

Why do you want to format SQL code?

As explained earlier, the formatted SQL code will makes your life easy. For example, consider below code that is extracted from the database. This query is to get information on customer return details from TPCDS benchmark tables.

select sr_customer_sk as ctr_customer_sk ,sr_store_sk as ctr_store_sk ,sum(SR_REVERSED_CHARGE) as ctr_total_return from store_returns ,date_dim where sr_returned_date_sk = d_date_sk and d_year =1999 group by sr_customer_sk ,sr_store_sk limit 10;

As you can see from above example, SQL code is messy and hard to understand. Now let us format it.

select 
  sr_customer_sk as ctr_customer_sk, 
  sr_store_sk as ctr_store_sk, 
  sum(SR_REVERSED_CHARGE) as ctr_total_return 
from 
  store_returns, 
  date_dim 
where 
  sr_returned_date_sk = d_date_sk 
  and d_year = 1999 
group by 
  sr_customer_sk, 
  sr_store_sk 
limit 10;

Look at the formatted code. It is lot simpler is it not?

There are many free SQL code formatting tools available for free. I will list few of them in this post.

  • Code Beautify SQL Formatter
  • Instant SQL Formatter
  • SQL Formatter

Code Beautify SQL Formatter

So far this is the best free SQL code format tool that i have used. It is simple to use and understand. The codebeautify has developed lots of formatting tools such as XML formatter, JSON validator, JSON editor, etc.

The beautify about this tool is you can format PL-SQL procedure tool.

Link: https://codebeautify.org/sqlformatter#

Best SQL Query Format Tools - Code Beautify SQL Formatter

The codebeautify tools works smoothly even if your query is large and complex.

Instant SQL Formatter

Another easy SQL format tool that i have used is an instant SQL formatter. This works well when you have small SQL queries. But with large query, it may stuck sometime depends upon the complexity of your query.

Link: http://www.dpriver.com/pp/sqlformat.htm

Best SQL Query Format Tools - Instant SQL Formatter

SQL Formatter

Another simple and easy to use tool is SQL Formatter. It is lightweight and works as expected with small queries.

Link: https://www.freeformatter.com/sql-formatter.html

Best SQL Query Format Tools - SQL Formatter

Disclaimer: Note that, I have used these tools to format SQL queries which are not confidential. Check with your admin teams about usage of any of the above mentioned tools.

Hope this helps 🙂