Skip to content
CleanGlyph home

SQL Formatter

Format SQL queries for Standard SQL, PostgreSQL, MySQL, SQLite or SQL Server. Choose keyword case and indentation, then copy readable SQL. Layout only: nothing is validated, executed or uploaded.

Your text never leaves your browser.

0 code points · 0 linesNot formatted yet

SQL formatting options

Before 0After — lines

Select Format SQL to see the result

How to use this SQL formatter online

Paste a query, or several statements separated by semicolons, into the SQL input. Pick the dialect, keyword case and indentation, then select Format SQL. To format a SQL query you copied from logs, an ORM or a migration, paste it as is: the SQL beautifier puts each clause on its own line, indents column lists and conditions, and leaves one blank line between statements.

Input
select id,name from users where active=1;
Standard SQL, uppercase, 2 spaces
SELECT
  id,
  name
FROM
  users
WHERE
  active = 1;

Choosing a dialect

Each database quotes identifiers and writes placeholders differently, so the formatter needs to know which rules to read the query with. Choose the database the query is written for. If formatting fails, the matching dialect usually fixes it. The dialect only controls how the text is read; it never converts SQL from one database to another.

Quoted identifier and placeholder style per dialect
DialectQuoted identifierPlaceholders
Standard SQL"order"?
PostgreSQL"order"$1
MySQL`order`?
SQLite"order"?, :name
SQL Server (T-SQL)[order]@name

Layout only, never validation

Format SQL lays out query text. It does not connect to a database, check table or column names, or run the query. String literals, quoted identifiers, comments, placeholders, statement order and semicolons are kept, and values are never substituted. When formatting would change more than whitespace and keyword case, the tool reports the query as unsupported instead of returning altered SQL. The safeguard also checks known cases where whitespace matters, including newline-separated PostgreSQL literals and MySQL function calls. It is not a guarantee that every unusual construct is detected, so review output before running it.

Custom delimiters, MySQL executable comments, stored procedure scripts, templated SQL and dialect conversion are not supported. Some multiline comments that the formatter would reindent are also rejected to keep their contents exact. Input is limited to 256 KiB and is processed in your browser only.

Generate escaped INSERT statements from a spreadsheet export with the CSV to SQL INSERT Generator, then format them here. Compare two versions of a query with the Text Difference Checker.

Frequently asked questions

How do I format a SQL query online?

Paste your query into the SQL input, choose the dialect, keyword case and indentation, then select Format SQL. Copy the formatted SQL when it appears. Changing the input or any option clears the old result so you never copy stale output.

Is my SQL sent to a server?

No. Formatting runs in a background worker inside your browser. Your SQL stays in browser memory and is not uploaded, logged, stored or added to the page URL.

Does the SQL formatter validate or run my query?

No. Format SQL only lays out query text. It does not connect to a database, check that tables or columns exist, or execute anything. A query can format cleanly and still fail when you run it.

Are placeholders like $1, ? and @id kept?

Yes. Placeholders supported by the selected dialect, such as $1 in PostgreSQL, ? in MySQL and SQLite, and @name in SQL Server, are kept exactly as written. Values are never substituted into the query.

Which dialect should I choose?

Choose the database the query is written for. Dialects differ in how they quote identifiers and write placeholders, for example backticks in MySQL and square brackets in SQL Server. If formatting fails, selecting the matching dialect often fixes it.

What does the SQL beautifier change?

Only line breaks, indentation and spacing, plus keyword case when you choose Uppercase or Lowercase. A safeguard checks tokens, literal and comment contents, and known boundaries where whitespace matters. Queries it cannot preserve are reported as unsupported with no output, including MySQL executable comments. This is not syntax validation or a guarantee for every database construct; review SQL before running it.