Most SQL arrives ugly. It comes pasted from an ORM log, copied out of a BI tool, or hand-typed onto a single line in a hurry. It runs fine — but reading it, reviewing it, or pasting it into a ticket is a chore. Today we’re launching the SQL Formatter to fix that in one click.
What it does
Paste your query, choose whether keywords should be uppercase or lowercase, pick your indentation (2 spaces, 4 spaces, or a tab), and the formatter hands you clean, readable SQL. Every major clause — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING, LIMIT, UNION — starts its own line, and the columns, ON conditions, and AND/OR predicates get indented underneath where they belong.
A cramped one-liner like select u.id,u.name from users u inner join orders o on u.id=o.user_id where u.active=1 comes back as a tidy, clause-per-line block you can actually scan.
Why we built it differently
The naive way to format SQL is to find the word “select” and uppercase it. That breaks the moment your query contains a string literal like 'select all rows' or a comment — both of which a careless formatter will happily corrupt.
Our formatter tokenises the query first: it classifies every piece as a keyword, identifier, string, number, operator, or comment before touching anything. That means it only re-cases real keywords and only reflows whitespace between tokens — your string literals and comments come back byte-for-byte identical. If you want the full picture of the conventions it applies, our guide to formatting SQL walks through clause-per-line layout, keyword casing, and why tokenising matters.
Pairs well with
Formatting SQL is part of the same toolkit as cleaning up any other code or data format. After you tidy a query, the JSON Formatter does the same job for API payloads, and the CSS Beautifier handles stylesheets.
What’s next
The free single-query formatter is here to stay. For teams that want one house style across an entire repo, we’re planning a Pro tier with saved formatting profiles, batch-formatting whole folders of .sql files, dialect-aware rules, and a CLI/API you can drop into CI. For now, make your queries readable for free — try the SQL Formatter.
Related Posts
EMI API in React
Integrating the Tools.Town EMI API in a React App — A Complete Walkthrough
8 min read
Binary to Text - Now Live
Introducing the Binary to Text Converter — Two-Way and UTF-8 Aware
3 min read
Canonical Tag Generator - Now Live
Introducing the Canonical Tag Generator — Fix Duplicate URLs in Seconds
3 min read
Frequently Asked Questions
Does it change my query's results?
Is it free, and does it store my SQL?
Explore more on Tools.Town Blog
Finance guides, tool launches, and engineering stories — updated weekly.