How to format and beautify SQL queries
- Paste SQL source or use Choose SQL file.
- Select SQL dialect, Indentation and Keyword case.
- Select Format SQL, then use Copy result or Download SQL.
Format SQL and beautify compact queries
Use this SQL formatter and SQL beautifier when a query arrives as one long line in an application log, ORM trace or migration script. When you format SQL or beautify SQL, consistent line breaks and indentation separate SELECT columns, JOIN conditions, WHERE filters and common table expressions. Keep semicolons between statements so multi-statement scripts format cleanly along with their comments, and copy or download the UTF-8 .sql result directly from your browser.
Match the SQL dialect and keyword case
Choose the right SQL dialect — Standard SQL, PostgreSQL, MySQL, SQLite, T-SQL or BigQuery — before formatting. Quoted identifiers, backticks, bracketed names, array operators and positional parameters such as $1 or @param follow dialect-specific rules. Set keyword case to Preserve when you want a layout-only diff, or switch to uppercase or lowercase with 2-space or 4-space indentation to match your repository style guide.
Review the script and its changes
To see every line that changed before committing a migration, compare the original and formatted scripts in the code diff checker. Use the JSON formatter to inspect JSONB payloads separately or the UUID generator to produce primary keys for test fixtures.
For JSON data that needs a different format, open the JSON converter.
Frequently asked questions
Which dialects are available?
Standard SQL, PostgreSQL, MySQL, SQLite, T-SQL and BigQuery.
Can I format several statements at once?
Yes. Paste or open a script up to 100,000 characters. Keep its statement separators intact.
What are the default layout settings?
Standard SQL with two spaces per indentation level and the existing keyword case.
Does formatting run the query?
Formatting reads the source and produces text on your device. It requires no database connection.
Why does a query report an error?
Check for unclosed quotes and select the source dialect, especially for vendor-specific operators, quoting and parameter syntax.
Last updated November 11, 2026