Improve SQL formatter to actually reindent/reformat SQL snippets

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Description

At least when working with a complex Rails application with complex associations the resulting SQL is often impossible to understand without first pumping it through a web site like http://poorsql.com/. We find we do this with all but he most trivial SQL when creating issues and often when we get lazy in subsequent comments this actually impedes people from understanding the changes.

Proposal

I found this handy MIT-licensed client-side javscript code to format SQL code here https://github.com/zeroturnaround/sql-formatter

It would be nice if the ```sql blocks could provide a little dropdown or button to allow the user to reformat and reindent the SQL live using it as well as highlight the keywords. I do think it would be good for this to be client-side and optional so you can see the original formatting if you choose.

It would be really neat if we could do something like explain.depesz as well but afaik that's entirely server-side and there's no similar tool that runs client-side.

Links / references

Edited Aug 25, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading