About SQL Formatter
SQL pasted from logs, drivers or ORM debug output is usually one dense line with inconsistent capitalization. Beautifying it makes joins, subqueries and WHERE clauses readable in a review or a ticket. The opposite need appears just as often: a query that must fit on one line for a config value, a shell argument or a compact log entry, where comments and indentation are pure overhead.
This formatter runs sql-formatter in the browser. It supports Standard SQL, MySQL, PostgreSQL, SQLite and BigQuery, can uppercase, lowercase or preserve keyword case, and reformats the whole script rather than guessing at just the first statement. Minify is a separate pass that removes comments and collapses whitespace outside string literals, so values that contain spaces are not touched. There is no database connection and no query execution: the text is only ever formatted on your device.
What this tool does
Five SQL dialects
Choose Standard SQL, MySQL, PostgreSQL, SQLite or BigQuery so quoting rules, operators and functions are parsed with the right grammar.
Format or minify
Beautify a query into indented clauses, or collapse it to a single line by removing comments and redundant whitespace outside strings.
Keyword case control
Uppercase keywords, lowercase them or preserve the original casing, including for formatting a script whose style you must match.
String-aware minification
The minifier tracks quoted strings, identifiers and comments, so spaces inside a value survive even when the surrounding query is compressed.
Error messages instead of silence
If the selected dialect cannot parse the input, the formatter reports the problem instead of returning unchanged text that looks formatted.
Copy and download
Copy the formatted or minified SQL with one button or download it as a .sql file, ready to paste into a migration or a ticket.
How to use SQL Formatter
- 01
Paste your SQL
Put the query or script in the input pane. Multi-statement scripts are accepted and formatted clause by clause.
- 02
Pick a dialect
Select the database that will run the query. Dialect affects identifier quoting, operators and function parsing, so pick the closest match.
- 03
Choose keyword case
Upper case is the usual convention for SQL keywords; lower case suits some style guides, and preserve keeps the casing you wrote.
- 04
Format or minify
Press Format for indented, readable SQL, or Minify for a single-line query with comments removed.
- 05
Copy or download
Review the result, then copy it or download a .sql file. Nothing is executed and no connection to a database is opened.
Supported formats and limits
- Input
- SQL
- Output
- SQL
- Processing
- Client-side, in your browser. Nothing is uploaded.
- Maximum size
- Bound by the memory available to your browser tab.
- Requirements
- Chrome, Edge, Firefox or Safari · JavaScript enabled
Limitations worth knowing
- Formatting is syntax-aware but not a validator: it may accept a query that the database still rejects, and vendor-specific syntax can fail to parse.
- Minify removes comments, so keep the original if the comments are documentation you need to preserve.
- Input is limited to 2 MB of SQL, and formatting runs on the main thread after a short yield.
- No database connection is made and no query is executed, explained or optimized.
Privacy and file handling
Your SQL is parsed and formatted inside this browser tab. Nothing is uploaded, stored, logged or executed, and no database connection is opened. Closing the page discards the input and the formatted result; the only outbound action would be a copy or download that you start yourself.
Read the full privacy policy