Development Tools
SQL Formatter
Paste a SQL query and get it back readable: keywords in a consistent case, each major clause (SELECT, FROM, WHERE, GROUP BY and so on) on its own line, one item per line in column lists, AND and OR conditions broken out, and sub-queries and CTEs indented. Strings, quoted names and comments are preserved exactly. It is a dialect-neutral layout tool: it does not parse, validate or run your SQL, so unusual syntax in a particular database may be laid out imperfectly, and it should never change what a query does.
How to use it
- Paste your SQL.
- Choose the indent width and keyword case.
- Copy the formatted result and check it still reads as intended.
Example
select a,b from t where x=1 and y in (select id from u) becomes a layout with SELECT, FROM and WHERE on separate lines, the list items indented, and the sub-query on its own indented lines.
Why format SQL
Consistent layout makes queries easier to review, compare and debug. The text compare tool works well for spotting changes between two versions once both are formatted the same way.
Which tool fits your task?
This page is for tidying SQL queries.
- JSON Viewer: for validating and formatting JSON, not tidying SQL queries.
- XML Formatter and Validator: for checking and indenting XML, not tidying SQL queries.
- CSV Viewer and Cleaner: for sorting, filtering and cleaning a CSV file, not tidying SQL queries.
- JSON to CSV and CSV to JSON Converter: for converting between JSON and CSV, not tidying SQL queries.
Questions
Does it change what my query does?
It only changes whitespace and keyword case. Text inside strings, quoted identifiers and comments is not touched. Still, run formatted code through your usual tests.
Which databases are supported?
It is dialect-neutral and works for typical MySQL, PostgreSQL, SQL Server, SQLite and Oracle queries. Procedural code and vendor-specific syntax may be formatted less neatly.
Does it find syntax errors?
No. It does not validate SQL; your database does that.
Is it safe to paste a query with real data?
The query stays in your browser and is not sent anywhere. Even so, avoid pasting credentials or personal data into any tool.
Why are function calls not broken across lines?
Arguments inside function parentheses stay on one line to keep expressions readable.
Get practical SEO tips by email
Occasional emails with new guides and tools. Confirm by email first; unsubscribe in one click.