SQL Format API - Pretty-Print Queries with Keyword Casing
Uppercases SQL keywords, normalizes whitespace, and inserts newlines before major clauses (SELECT, FROM, WHERE, JOIN variants, GROUP BY, ORDER BY, UNION, and more). Subqueries are indented by the configured number of spaces. Dialect-agnostic within standard ANSI SQL.
Code examples
curl -X POST https://api.botoi.com/v1/sql/format \
-H "Content-Type: application/json" \
-d '{"sql":"select id,name from users where active=true order by created_at desc","indent":4}'When to use this API
Format logged slow queries for review
When your DB exposes slow queries as single-line log entries, format them before pasting into a ticket. Reviewers can read the structure without visually parsing wrapped text.
Normalize queries in migration files
Pre-commit hook that formats every .sql file. Keeps migrations uniform across contributors and makes diffs easier to review.
Render LLM-generated SQL in your UI
LLMs often return compact single-line SQL. Format it through this endpoint before rendering so users see a clean multi-line query instead of a wall of text.
Frequently asked questions
Which SQL dialects are supported?
How is subquery indentation controlled?
What happens with keywords that appear as identifiers?
Does this parse the query?
Will it fix dangerous queries?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.