5 Best Free Online SQL Formatter Tools

1. Introduction

The official meaning for the verb format is to convert a code from an initially defined style that you wrote into a standard generic format.
SQL format tool will allow you to convert a “handwritten” SQL format into a pettier visual format to be more easily readable. The readability decreases direct proportional with the length of the query this will cost the time you understand the entire query (this is basically when you have nested queries).

2. About SQL

SQL is the Standard Query Language used to query information from a table in a relational database. The language became a standard for ANSI (American National Standards Institute) in 1986, and one year later became ISO (International Organization for Standardization) as Wikipedia related.
This is used by Data Analysis, Data Engineer or Data Science.
The most popular databases so far are Oracle, MySQL, SQL-Server, Postgress, and IBM, and others as DB-Engines related
When you write an SQL query you shouldn’t worry about formatting will be different, from one dialect o another. Formatting a query should not depend on which dialect you wrote.

3. SQL Style best practice

These best practices were inspired by a book about SQL design written by Joe Celko. Most of these best practice was summarised on this website.
As a general overview about storing information in SQL:

Best practice about indentation, white spaces/line spaces in a query syntax:

4. 5 Best free online SQL formatter tools

Below are the best 5 online websites that format SQL queries.
I ranked the below websites from the accessibility point of view and how much you can customize in the formatting process, giving also the possibility to select the SQL dialect.

4.1 Dbriver https://www.dpriver.com/pp/sqlformat.htm

After you open the website you will be able firstly to select your SQL dialect through selecting the database. You can specify the output of the formatting SQL in many formats: HTML format with different blocks, a simple output text or even to output the formatting SQL in different languages like C#, Java, PHP, and others. Besides that, you will be able to specify how to formatting SQL queries should behave. You can specify to upper case all the SQL keywords to the table name, column name, the variable case even specify max length per line in compact mode. Below is a screenshot of the webpage interface.

4.2 PoorSQL https://poorsql.com/

The second website have pretty much the same custom fields to format SQL query. When you want to format a SQL query will have to insert your SQL query in the first tab: ‘Input SQL’ and after that to switch to the second tab: ‘Formatted SQL’ to see the result. This website will do a syntax check for the given query and will highlight where is the problem.

4.3 SQL Format https://sqlformat.org/

This website offers some limited options to format the SQL query. Besides the rest of the website, offers an API or a python module to use in your project to automatically format your queries.

4.4 Extendsclass https://extendsclass.com/sql-formatter.html

ExtendsClass website offer pretty much the same functionality from the customizing the output format for an SQL query the possibility to download the result file.

4.5 Codebeautify https://codebeautify.org/sqlformatter

The last one is a basic SQL Formatter online tool where you can type SQL quest to format. This tool allows you also to upload an SQL file or a link with some SQL queries to format. This website will provide different dialect beside SQL like N1QL and DB2.

If you use InteliJ Idea a basic useful formatter plugin is: SQL Formatter that you can install from your InteliJ. Go to File -> Settings -> Plugins -> Select ‘Marketplace’ and then type: SQL Formatter and install. After you installed on the right side of the InteliJ you will see a tab: ‘SQL Formatter’. Copy and Paste your query in the test area and press the ‘Format’ button.

5. Conclusion

In this article, you got familiar with what SQL format means, and how it will help you daily basis when working with SQL queries. We follow some of the best practices when you want to indent your query manually. Besides the theoretical part, you will find some online free tools for formatting SQL queries.

Exit mobile version