
Building a Lightweight SQL Formatter with FastAPI and sqlparse
Why I Built a SQL Formatter I often run into messy SQL queries while working with databases. Sometimes queries come from logs, dashboards, or teammates and they’re hard to read because everything is on one line. Instead of opening an IDE just to clean up the query, I wanted a quick tool where I could paste SQL and instantly get a readable version. So I built a small SQL formatter. The tool is available here: https://sql-formatter.dev What the Tool Does The formatter takes a SQL query and returns a formatted version with proper indentation and readable structure. Current features include: indentation control keyword case toggle (UPPER / lower / preserve) SQL syntax highlighting copy formatted SQL download formatted SQL as .sql automatic formatting on paste Architecture I wanted to keep the architecture extremely simple. Backend The backend is a small Python service built with FastAPI. Formatting is handled using the sqlparse library: python formatted = sqlparse.format( sql, reindent=Tru
Continue reading on Dev.to Python
Opens in a new tab


