How to use SQL Formatter
- Paste a SQL query or script into the editor.
- Choose its SQL dialect and keyword case.
- The formatted SQL updates as you change the query, dialect or keyword case. Review it before running it in your own database.
Example: SQL Formatter
Lay out a SELECT query with uppercase keywords and two-space indentation.
Options
- SQL
- Formatting changes spacing and keyword case. It does not validate or execute SQL.
- SQL dialect
- The dialects the formatter in this page supports. 21 are offered, from Standard SQL to Snowflake and T-SQL.
- Keyword case
- Change recognized SQL keywords to uppercase or lowercase, or preserve their original case. This does not check table names or query permissions.
- Indent width
- The number of spaces one indent step uses. Two suits most reviews; four suits a house style that indents by four.
Supported inputs and limits
- Formatting changes layout and, if selected, keyword case.
- It does not parse against your database schema, check permissions or prove the query is safe.
- Choose the closest supported dialect; vendor extensions may format imperfectly.
- Input is capped at 200,000 characters.
- The bundled formatter changes layout, not database behavior.
More details
SQL minification is not provided.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Questions about SQL Formatter
Will this page run my SQL?
No. It only rewrites text in your browser and has no database connection.
Which dialect should I choose for MariaDB?
Choose MariaDB; its keywords and syntax can differ from other SQL engines.
Does a formatted query mean it is valid?
No. Formatting does not check table names, data types or whether the query will run.
Can formatting change my comments?
The formatter tries to retain comments, but spacing around them can change. Review the result before use.