SQL Query Formatting Tools Used At Percona

SQL Query Formatting Tools Used At PerconaPercona engineers often need to analyze and review complex SQL database queries. Good formatting can make these SQL queries much easier to understand and work with. Without clear formatting, queries can become confusing and hard to debug.

Online query formatting services provide one set of solutions. Examples are Code Beautify, FreeFormatter, and sqlformat.org. However, many users are not comfortable sharing their queries with third-party services, especially if your SQL code contains confidential information.

This article examines alternatives to online tools for SQL query formatting tools that have been successfully used by Percona engineers. These solutions come in different types:

  1. Plug-ins to your code editor or IDEs.
  2. Database Management tools
  3. Terminal Tools

Let’s examine these options.

Code editor or IDE

Most modern code editors have functionality or plug-ins for formatting queries. We checked Visual Studio Code and Sublime because these popular code editors are available for Linux, Mac, and Windows.

Visual Studio Code knows how to format SQL queries, as well as available Extensions for working with databases, for example, “SQLTools – Database tools”. Sublime does not have SQL formatting as standard functionality, but it is easy to add it through Package Control. Several packages are available for Query formatting, and we used Sql​Beautifier.

In this case, you need to copy the request to the code editor and save it to a file. It turned out that most of the Percona team use console tools.

SQL query formatting



DBA tools

Special database management and monitoring software also have functionality for query formatting.

MySQL Workbench

MySQL Workbench enables a DBA or developer to visually, generate, and manage databases.

The Workbench allows you to format an SQL query into a new SQL tab and click the “Beautify/reformat the SQL script” button.

SQL query formatting


Percona Monitoring and Management (PMM)

Percona Monitoring and Management (PMM) is a free, best-of-breed, open-source database monitoring and management solution. PMM has the useful functionality of PMM Query Analytics, which allows you to immediately view requests in formatted form.

percona monitoring and management


Terminal tools

The most popular console tool for formatting queries in our team is sqlparse (sqlformat). The developers of the popular online service SQLFormat were very kind and provided the source code of their excellent tool (sqlparse). This simple and useful tool you can use on different platforms.


If you love Docker and do not want to install the tool on your system. Percona Support Engineer Agustín Gallego has packed the data script into a docker. Here is a simple instruction on how you can use it.

Cool, right? 🙂


It’s very simple, install the sqlformat package.


Install sqlparse using brew or another way to use the command sqlformat.


And if you love and use VIM, you can also install sqlformat and use it.

Sqlformat in VIM


We looked at Sqlparse and Sqlformat tools and their use on Linux, Mac, or Windows. We would like to note that it is very convenient for developers to use the Code Editor or IDE, especially if you become a regular user. Additionally, specialized database software such as MySQL Workbench or PMM can help with query formatting. These are SQL query formatting tools that the Percona team has utilized successfully. Share your experience with these or other tools here in the blog comments.

We understand that choosing open source software for your business can be a potential minefield. You need to select the best available options, which fully support and adapt to your changing needs. In this white paper, we discuss the key features that make open source software attractive, and why Percona’s software might be the best option for your business.

Download “When is Percona Software the Right Choice?”

Share this post

Leave a Reply