SQL Formatter

An SQL formatter rewrites a query with consistent line breaks, indentation and keyword case so it is easier to read and review. This free tool formats SQL as you type for 14 dialects including MySQL, PostgreSQL, SQL Server, Oracle PL/SQL, BigQuery and Snowflake, lets you choose keyword case and indentation, and can minify a query to one line.

Free, no signup. Runs entirely in your browser; files and text are not uploaded.

How to use the SQL Formatter

  1. Paste a query into the SQL input box, open a .sql file, or click Load sample.
  2. Choose your database in the Dialect list.
  3. Pick the Keyword case and Indentation you prefer.
  4. Tick Minify to one line if you need a compact query.
  5. Copy or download the formatted SQL.

Features

  • Formats as you type using the open-source sql-formatter library
  • 14 dialects including MySQL, PostgreSQL, T-SQL, PL/SQL, BigQuery, Snowflake and SQLite
  • Uppercase, lowercase or preserved keyword case
  • 2-space, 4-space or tab indentation
  • Minify to one line without touching string literals
  • Parse errors shown with the failing line and column
  • Open .sql files, copy and download

Frequently asked questions

Which SQL dialect should I choose?

Pick the database the query runs on. Dialects differ in quoting, operators and keywords, such as T-SQL square brackets or PostgreSQL :: casts, and the matching dialect avoids parse errors. Standard SQL works for simple queries.

Does formatting change what my query does?

No. Only whitespace, line breaks and, if you choose, keyword case change. Identifiers, string literals and comments are kept as written.

Why do I get a parse error?

Usually there is an unclosed quote or bracket, or the query uses syntax from a different database. Check the position in the error message and select the dialect your database uses.

Is my SQL sent to a server?

No. Formatting runs in your browser, so queries containing table names or data never leave your device.

Related tools

  • JSON Formatter – Beautify, minify and validate JSON with error line numbers, key sorting and auto-fix
  • HTML Formatter – Indent or minify HTML, keep pre/script content safe and flag unclosed tags
  • CSS Formatter – Beautify or minify CSS with safe handling of selectors, strings and url() values
  • Regex Tester – Test JavaScript regular expressions with live highlighting, groups and replace preview

Built and reviewed by Naqash Thaheem, Technical Project Manager. Last reviewed 2026-09-24.