Skip to main content
ConduitTools by ConduitCode Labs

Developer

SQL Formatter

Waiting for SQL
SQLPaste one or more queries, or drop a .sql file
ResultUpdates as you type
.sql
Nothing to format yet

Paste a query, or load the sample, to see it laid out one clause to a line.

0 BInput size
—Output size

Paste a long, tangled query and get it back one clause to a line, with keywords in the case you choose. Pick your database so its syntax is read correctly.

  • Free
  • No sign-up
  • Runs in your browser

How to use this tool

  1. Paste one or more SQL queries, drop a .sql file, or press Sample.

  2. Choose your Dialect, such as PostgreSQL, MySQL or SQL Server, so its syntax is read correctly. Set Keywords to UPPERCASE, lowercase or As written, choose the Indent, and decide whether AND / OR start the line. Choose One line to squeeze the query onto a single line instead.

  3. An unfinished string, comment or bracket is reported with its position. When the result looks right, press Copy result or Download.

How to use this tool
  1. Paste one or more SQL queries, drop a .sql file, or press Sample.

  2. Choose your Dialect, such as PostgreSQL, MySQL or SQL Server, so its syntax is read correctly. Set Keywords to UPPERCASE, lowercase or As written, choose the Indent, and decide whether AND / OR start the line. Choose One line to squeeze the query onto a single line instead.

  3. An unfinished string, comment or bracket is reported with its position. When the result looks right, press Copy result or Download.

Was this tool helpful?

Suggest an improvement

Help keep ConduitTools free

Every tool here is free, private and built by a solo developer. If this one saved you time, a small tip keeps the site running and new tools coming.

What it handles

Queries you can read at a glance.

A one-line query with six joins is hard to review. This lays it out with each clause on its own line, joins and conditions indented, so mistakes stand out.

A clear layout
SELECT, FROM, WHERE and the rest start their own lines, columns are listed one per line, and nested brackets are indented. Choose 2 spaces, 4 spaces or tabs.
Your database's dialect
PostgreSQL, MySQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake and others each have their own quoting and functions. Choose yours so they are read as written.
Nothing inside strings changes
Text in quotes, comments and dollar-quoted blocks is left exactly as you wrote it. An unfinished string or comment is reported instead of being guessed at.

Frequently asked questions

Does formatting change what my query does?

No. Only spaces and line breaks change, and optionally the case of keywords. Strings, names and comments are left as they are, so the query runs the same.

Why do I get an error for a query that runs on my database?

Most likely the dialect. Each database has syntax the others lack, so choose yours. If it still fails, the message gives the line and column of the first thing that could not be read.

What does One line do?

It removes comments and squeezes spaces and line breaks into single spaces, giving a compact query to paste into code. Text inside quotes is left untouched.

Can I format several queries at once?

Yes. Separate them with semicolons and each is formatted in turn, with a blank line between them.

Should keywords be uppercase?

It is a convention, not a rule. Uppercase keywords make the structure of a query easier to see, but lowercase or As written work just as well. Names of tables and columns are never changed.

Keyboard shortcuts

Press navigation keys one after the other. Single-key shortcuts work outside text fields.

Ctrl+K
Search all tools
/
Focus directory search, or search all tools on other pages
GthenH
Go to the homepage
GthenT
Browse all tools
GthenF
Open FAQs
Ctrl+Enter
Copy or download the result
Ctrl+Shift+Enter
Generate a new password or new text
?
Show this list
Esc
Close a dialog or menu
↑↓
Move through tool search results
Enter
Open the selected search result