Py-SQL-cleaner
format SQL embedded in Python strings
Get picks like this daily. Today's launch numbers, the top launches, AI and tech news, and a daily opportunity pick, straight to your inbox.
Want to reach these readers? Sponsor an issue.
Hi HN, I built py-sql-cleaner, a CLI for formatting SQL embedded in Python files.Python formatters handle Python syntax. They do not format SQL written inside Python code. On the other hand, SQL formatters usually target SQL files or raw SQL text, not SQL embedded inside a Python file.Still, I think it is not uncommon to find long SQL queries inside Python codebases.py-sql-cleaner detects embedded SQL inside Python files and works only on that SQL. The main things it can do are: find the SQL, format it in place, or extract it into a .sql file.It avoids rewriting SQL that depends on runtime values or template expansion. For example, SQL containing parameters like %s or :name, or Jinja-style template variables like {{ ds }}, is skipped by default.Try it with: uvx py-sql-cleaner list path/to/file.py uvx py-sql-cleaner format path/to/file.py --dry-run If you write Python, have run into this kind of SQL cleanup problem, or are just curious, I’d be happy if you take a look.
HN · launched May 28, 2026 · 7 upvotes (top 58%) · 0 views
Niche: data parsing libraries and tools · 71 launches, 1 in the last 7 days · Explore this niche →
Category and tags
- Horizontal
- Dev tools
- Developer
- Not AI
- Hobby / open-source project
Visit website ↗ Source listing ↗
More like this: all 71 launches in data parsing libraries and tools →
Could you build this?
Yes It is a focused CLI utility that parses Python code (likely via python's `ast` module or tree-sitter) to find SQL string literals and pass them to an existing SQL formatter library.
Discussion
No comments on this launch.
Competitors
Other products that read as similar to this one : 177 launches clear the similarity bar, closest 8 shown.
Attention rank: #84 of 178 (itself plus its competitors, highest first, normalized so YC and Product Hunt are compared fairly).
Launched 209 days after the earliest competitor.
- SQLazy · ph · 2026-09-21 · 2 upvotes · similarity 0.49
- PasteKit · ph · 2026-10-18 · 88 upvotes · similarity 0.46
- CSV Cleaner Express · ph · 2026-11-09 · 1 upvotes · similarity 0.45
- Clean messy CSV files in minutes... · ph · 2026-10-19 · 1 upvotes · similarity 0.45
- Sqlit · hn · 2025-12-15 · 190 upvotes · similarity 0.43
- Free Online Data Formatting Tools · ph · 2026-09-16 · 1 upvotes · similarity 0.41
- reylo · github · 2026-10-21 · 1251 upvotes · similarity 0.41
- dbdiff · ph · 2026-10-11 · 1 upvotes · similarity 0.41
The niche, labels, vibe code rating and competitor comparison on this page are analysis by Nicheloom. If you use them, please credit nicheloom.com. How you may use our data.