Developer tools

SQL formatter

Format SQL locally for PostgreSQL, MySQL, SQL Server, SQLite and more. Choose dialect, indentation and keyword case, then copy or download without executing queries.

Choose your database. Generic SQL is not automatic detection.

Indentation, keywords and query layout

10–120 characters. Controls when short expressions stay on one line; it is not a maximum line length.

Paste SQL, or import one UTF-8 file up to 1 MiB.

Source: editor text.

Import a SQL file or drop it here

Choose your formatting options and format when ready.

Format for your database

Select the database dialect before formatting. Twenty dialect choices cover PostgreSQL, MySQL, SQL Server, SQLite, BigQuery, DuckDB and other supported engines. Generic SQL handles a common subset; it does not detect or convert a dialect. IBM Db2 for i support is experimental.

Paste SQL or import a UTF-8 SQL/TXT file, choose indentation, then format and download. The example joins customers to paid orders and groups the results. Expand layout options to keep or change keyword case, control inline expression width, and set blank lines between statements. Identifier, function and data-type case are left unchanged; parameters are not replaced.

Formatting is not validation or execution

The tool rearranges whitespace and optional keyword case. It can format some invalid SQL, so a completed result does not prove a query will run or return the intended rows. It never connects to a database, executes a statement or optimizes a query. Stored procedures, custom DELIMITER commands, SQLCMD commands and template placeholders such as Jinja are outside the supported scope.

Quoted strings, quoted identifiers and parameter placeholders keep their source spelling. Comments remain in place, although surrounding whitespace can change. A dialect mismatch can cause formatting errors; check the selected database and the highlighted source location.

Original files and line endings

Imports retain original text for formatting, copy and download, including line endings inside multiline strings. The editor displays normalized line breaks; a notice appears when the original contains carriage returns. Editing or pasting in the text box uses its LF line endings. Undo replacement can recover the original imported text. Newly generated layout uses LF, while quoted content can retain original CRLF.

Import, example, clear, large paste and Use output as input provide one Undo replacement retained across option changes. Undo restores the saved source, database dialect, indentation, keyword case, expression width, statement spacing, editor wrapping and filename. Ordinary edits clear that history. Invalid imports preserve useful work; edits cancel obsolete processing and disable stale downloads. Clipboard denial selects output for manual copying.

Local processing and limits

A local worker processes source as text. Nothing is uploaded or saved automatically. Input is limited to 1 MiB, output to 4 MiB, with cancellation and ten-second deadlines for processing and file reading. UTF-8 downloads end in a newline; a leading byte-order mark is removed with a notice.

Powered by locally bundled SQL Formatter. SQL Formatter license; Nearley parser license.