SQL Formatter
Format SQL queries with a selected dialect and consistent uppercase keywords, without connecting to a database.
Loading tool…
How to use SQL Formatter
Make SQL easier to review with indentation and line breaks. Formatting runs locally and never executes a statement or opens a database connection.
- Paste a query or SQL script.
- Select the dialect used by your database.
- Format and review the result before using it.
Good to know
- Formatting does not execute, optimize, or fully validate a query.
- Up to 50,000 input characters. Some vendor extensions and template languages are unsupported.
- Always review changes before running SQL in a database.
Format a PostgreSQL query while retaining its string literal
Paste the query below and choose PostgreSQL. The formatter uppercases recognized keywords and places the selected column, table and condition on separate indented lines. The words select from inside the quoted string remain lowercase because they are data, not SQL keywords. Review changes before database use. Formatting neither connects to a server, checks table or column existence, nor executes SQL. The selected dialect guides parsing and formatting, so use the one matching the source query.
Query with SQL dialect set to PostgreSQL
select name from users where name='select from';
Expected formatted source
SELECT name FROM users WHERE name = 'select from';
- Other choices are Standard SQL, MySQL, SQLite, SQL Server / T-SQL and BigQuery. Vendor extensions or template expressions can still be unsupported.
- The source limit is 50,000 characters. A formatting error asks you to check syntax and dialect rather than attempting an automatic repair.
- Download produces formatted.sql containing text. The tool does not optimize a plan, validate permissions or certify that the query is safe to execute.
Common questions
Does the formatter need database credentials?
No. It works entirely with the text you provide.
Does uppercase formatting change string values?
Only recognized SQL keywords are uppercased; string literals retain their content.
Keep going with related tools
All developer →JSON Formatter
Format and indent valid JSON in your browser, with downloadable output and clear syntax errors.
DeveloperRegex Tester
Test JavaScript regular expressions in an isolated worker with a 250 ms timeout and readable match positions.
DeveloperSQL Schema Diagrammer
Turn a supported SQLite CREATE TABLE script into an original table-and-key SVG diagram with complete source and foreign-key mapping evidence.
FilesSQLite Snapshot Schema Inspector
Read schema objects and selected file-header metadata from a bounded standalone SQLite rollback-journal snapshot without executing SQL.
DeveloperPostgreSQL Query Plan Explorer
Explore supplied EXPLAIN JSON with node hierarchy, estimates and explicitly labeled actual metrics.
DataCSV to SQL Inserts
Generate quoted SQLite or PostgreSQL INSERT statements from CSV without executing SQL.