Skip to content
Codoryn Search tools

SQL Formatter

Reformat SQL into readable, consistent output — designed to change layout and keyword casing only.

What this formatter changes — and what it does not

The formatter is designed to change layout and configured keyword casing only — whitespace, line breaks and indentation. It is not designed to rewrite table or column names, string literals, comments, or the order of anything in your query.

Text inside quotes is treated as data rather than syntax, so selecting UPPERCASE keywords should leave a literal such as 'select from where' lowercase.

Codoryn cannot guarantee semantic equivalence for every query in every supported dialect, because formatting is performed by an external parser with its own coverage limits. Review generated SQL before running it, particularly for vendor-specific or procedural syntax.

How to use it

  1. Paste your query into the input pane, or press Sample to load an example.
  2. Pick the dialect that matches your database.
  3. Adjust keyword case, indentation, and where AND / OR line breaks fall.
  4. Press Format SQL or Ctrl/Cmd + Enter.
  5. Use Copy output or Download .sql to take the result away.

Choosing a dialect

Codoryn does not guess your dialect, because guessing wrongly produces confusing errors. Pick the database you actually use.

Standard SQL handles most portable queries. Choose a specific dialect when your query uses syntax that only that database accepts — square-bracket identifiers such as [dbo].[users] need SQL Server, backtick identifiers need MySQL or MariaDB, and :: casts or ->> JSON operators need PostgreSQL.

If formatting fails, the selected dialect is the first thing to check. Codoryn never switches dialects for you.

Before and after

Input:

select o.id,c.email from orders o join customers c on c.id=o.customer_id where o.total>100 and o.status<>'cancelled' order by o.id desc

Output with PostgreSQL, uppercase keywords and 2-space indentation:

SELECT
  o.id,
  c.email
FROM
  orders o
  JOIN customers c ON c.id = o.customer_id
WHERE
  o.total > 100
  AND o.status <> 'cancelled'
ORDER BY
  o.id DESC

A formatter is not a validator

This tool reports Formatted successfully — never Valid SQL. Those are different claims.

Formatting succeeds when the query can be parsed well enough to be laid out. It says nothing about whether your tables exist, your columns are spelled correctly, your joins make sense, or the query will run on your server. A query can format perfectly and still fail at execution.

When formatting fails, Codoryn says it could not format the query with the selected dialect. It does not tell you the SQL is invalid, because the real cause is often just the wrong dialect.

Known limitations

  • Stored procedures. The underlying formatter does not support every stored-procedure syntax. Complex procedural blocks may fail to format even when they are valid on your server.
  • Statement delimiter. Only ; is supported as the statement delimiter. Scripts that change the delimiter (for example DELIMITER $$ in MySQL routines) are not handled.
  • Size. Queries above 5 MB are refused in this version rather than risking an unresponsive tab.
  • No minifier. SQL minification is deliberately not part of this tool; doing it safely needs parser-aware handling of strings and comments, which belongs in a separate tool.

Frequently asked questions

Is my SQL uploaded anywhere?

No. Formatting normally runs in a Web Worker inside your browser. If worker execution is unavailable, the badge above the workbench says so, and only small queries are formatted on the main thread — larger ones are refused rather than freezing the page. Either way the query is processed in your browser, and this tool does not send it over the network.

Why did formatting fail on a query that works in my database?

Almost always the selected dialect. Vendor-specific syntax only parses under its own dialect. Stored-procedure bodies and custom delimiters are the other common causes.

Will formatting change my query results?

It is not designed to. Only layout and configured keyword casing are meant to change, and identifiers, literals and comments are meant to be preserved. That said, no external formatter can promise semantic equivalence across every dialect and query shape, so review the output before running it against a database.

Can I format several statements at once?

Yes. Separate them with ; and choose how many blank lines to leave between them.