Skip to main content

SQL formatting

Hex offers built-in SQL formatting, as well as the option to configure custom SQL linting.


Built-in SQL formatting

Clicking “Format code” from the 3-dot menu of a SQL cell will automatically format your query. To invoke the keyboard shortcut, first use esc to enter command mode, then f + s.

Custom SQL formatting


This feature is available for workspaces on Professional, Teams, & Enterprise plans.

It is possible to use a custom linter to format your workspace’s SQL queries whenever “Format code” is triggered.

Hex accepts SQLFluff configs to format your queries. In a data connection’s settings, simply upload a SQLFluff config; then the config’s rules will be used each time a query using that data connection is formatted. The uploaded file can be of any type, although .sqlfluff is considered the standard practice.

If no config file has been uploaded, Hex will use SQLFluff's default config to format your SQL. If you'd like to use your own formatting rules, you can use this config as a jumping off point, or create your own from scratch. SQLFluff’s configuration and rules reference docs are great resources for guidance on how to define your config file.

Please note that Hex uses SQLFluff 2.0. See the upgrade guide if you have any questions on how to update your config.