SQL Formatter
Make SQL queries readable, or minify them
Paste a long, single-line or messy SQL query and get it neatly indented with one clause per line. Choose your database dialect, the indentation and whether keywords are written in UPPERCASE.
The minify option does the opposite: it removes extra whitespace while keeping strings, quoted names and, if you want, comments exactly as they are.
How to format SQL
- Paste your SQL query or script.
- Select the SQL dialect, indentation and keyword case.
- Click Format SQL or Minify, then copy or download the result.
SQL formatter features
- Dialects: MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Oracle PL/SQL, BigQuery and more.
- Indentation with 2 or 4 spaces or tabs, and UPPERCASE or lowercase keywords.
- Formats very large scripts in the background without freezing the page.
- Clear error messages when a query cannot be parsed.
Why format SQL?
Formatted SQL is much easier to read, review and debug: you see at a glance which tables are joined, which conditions are applied and how the results are grouped. Minified SQL is useful when a query must fit on one line, for example in code or a configuration file.
Frequently asked questions
Is my SQL sent to a server?
No. Formatting runs in your browser, so queries that contain table names or data stay private.
Does it change what my query does?
No. Only whitespace and, if chosen, the case of keywords are changed.
Can it format several queries at once?
Yes. Paste a whole script; queries are separated by empty lines.
Privacy: your data stays on your device
This tool runs entirely in your browser. Your text, numbers, images and files are processed on your own device and are never uploaded to our server or shared with anyone. It is free, needs no sign-up and works on Windows, Mac, Android and iPhone.