Skip to main content

SQL Formatter

Reformat a SQL query for readability, entirely in your browser, using the sql-formatter library.

This tool formats text only. It never connects to a database or runs your SQL.

Formatting SQL does not make a query safe to execute and does not prevent SQL injection.

Processed locally in your browser

How to use it

  1. Paste your SQL query into the input box
  2. Choose a dialect, the keyword case, and the indentation width
  3. Click Format SQL to get the reflowed query
  4. Copy the result, or Clear to reset the input and options

Pick a dialect — Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), BigQuery, Snowflake, or Oracle (PL/SQL) — then choose whether keywords are uppercased, lowercased, or left as written, and whether to indent with two or four spaces. The formatter only changes whitespace and keyword case: the contents of string literals, line and block comments, quoted, backtick, and bracket identifiers, and parameter placeholders such as ?, $1, :name, and @name are all preserved. Multiple statements separated by semicolons are kept in their original order. It is a formatter, not a validator or an optimizer, and it never connects to a database or runs your SQL. Formatting also does not make a query safe to execute or protect against SQL injection. Everything runs locally, so the query you paste is never uploaded or stored. This is separate from the JSON Formatter, which reflows JSON syntax rather than SQL.

FAQ

We use cookies to run this site and, with your consent, to understand usage and personalize ads. You can change your choice at any time.