SQL formatter
Paste a SQL query to format it with clean line breaks and indents, for MySQL, PostgreSQL, SQL Server, Oracle, SQLite and more.
Your files stay on your device. Nothing is uploaded.
Step 1: Paste SQL
Step 2: Choose the style
Step 3: Copy the formatted SQL
How to format SQL
-
Paste SQL
Paste one query or several, separated by semicolons.
-
Choose the database and style
Pick your database so its own keywords are understood, and choose keyword case and indent.
-
Copy the result
Copy the formatted SQL or download a .sql file.
About this tool
Easier to read and review
Each clause (SELECT, FROM, JOIN, WHERE, GROUP BY) starts on its own line and columns are listed one per line, so long queries are easy to read and changes are easy to compare.
Dialects
Each database has its own syntax, such as backtick names in MySQL, :: casts in PostgreSQL or square brackets in SQL Server. Choosing the database makes these format correctly.
Your query stays private
Queries often include table names and data. Formatting happens in your browser; the query is not sent anywhere.
Privacy
This tool runs in your browser, on your own device. Your files and text are not uploaded to our server and we cannot see them. When you close or reload this tab, they are cleared, along with the results.
Frequently asked questions
Does formatting change what the query does?
No. Only spaces, line breaks and, if you choose, keyword case change.
Why does it say the SQL could not be read?
The query has a syntax the formatter does not understand, often an unclosed quote or bracket, or a dialect feature. Try choosing the right database.
Is my SQL uploaded?
No. It runs in your browser, so nothing you type or choose is sent anywhere.
Does it check my SQL is correct?
No. It formats the text; it does not run the query or check table names.
Related tools
- { JSON } JSON formatter Format, validate, minify and sort JSON.
- /.*/ Regex tester Test regular expressions with live highlights and groups.
- TS JSON to TypeScript Make TypeScript interfaces from a JSON sample.
- CSV › JSON CSV to JSON Turn a CSV table into a JSON array of objects.
- Diff Text compare Compare two texts and see what was added or removed.
- Epoch Unix timestamp converter Turn Unix timestamps into dates and dates into timestamps.
- Aa › AA Case converter Change text to upper, lower, title or sentence case.
- CSV › XLSX CSV to Excel Convert a CSV file to an Excel workbook and keep leading zeros.