Sublime Text 3 SQL format command
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This small piece of code adds the possibility to format SQL queries in sublime text 3 through a new command 'format_sql'. It takes some poorly formatted SQL code like this :

select * from STuff s where s.something > 42 limit 30

and turns it into this :

FROM stuff s
WHERE s.something > 42 LIMIT 30

Yep, I know, that's pretty awesome. Well, I'm not so sure about that, but anyway, that's really useful to me, and it may be to you to.


Clone this repository inside of the Packages/User repository, then map the new command to a key binding


Create the following binding in Preference / Key Bindings - User

{ "keys": ["ctrl+alt+f"], "command": "format_sql" }

External lib

I cloned the code for sqlparse from into the project because that permits an easier deployment.


I most likely won't do it, but if you feel like it, it would be nice to

  • be able to configure the way sqlparse
  • register the command in the package control


This code is released under the MIT license.