Asistente RD

SQL formatter

Free SQL formatter that runs in your browser: uppercase keywords, line breaks before every clause and clean indentation for SELECT, JOIN, WHERE and ORDER BY.

Free · No sign-up · In your browser

Formatted SQL
Type or paste a SQL query to see it formatted.

Keywords are uppercased and each clause starts on a new line. Table, column and function names are left exactly as you typed them.

Everything runs locally in your browser with JavaScript: your SQL is never sent to any server.

Share on WhatsApp Last reviewed: July 9, 2026

What this SQL formatter does

Queries have a habit of arriving as one endless line — pulled from a query log, an ORM’s debug output or a coworker’s chat message: select id, name from users where age > 18 order by name. It runs fine, but it is painful to read and review. This formatter rewrites that exact query as a tidy block: keywords in uppercase, a line break before every clause, and consistent indentation for column lists, JOINs and conditions.

Everything happens in your browser with JavaScript. It is not a database engine and runs nothing — it only rearranges the text so a human can read it. That means you can paste queries that mention internal table names, emails or customer data without any of it leaving your screen.

How to use it

  1. Paste your query into the input box (or click Load example to see one).
  2. The formatted result appears instantly below — there is no button to press.
  3. Click Copy to send the tidy SQL to your clipboard.
  4. Clear empties the box so you can start again.

The rules it applies

The formatter walks through the query, splitting it into pieces (words, quoted strings, parentheses and symbols), then applies a fixed set of rules. It tracks quoted strings, so a 'NY' or an 'ORDER by house' inside quotes is never touched.

ElementWhat the formatter does
SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVINGNew line, no indent (main clause)
JOIN, INNER JOIN, LEFT JOIN, RIGHT JOINNew line, indented under the FROM
AND, ORNew indented line inside the WHERE
ONStays on the same line as the JOIN
Comma between columnsEach column drops to its own indented line
Table, column and function namesLeft exactly as you typed them

Note that last row: only the language’s keywords are uppercased. A count(*) or a now() keeps its original casing, because those are functions, not structural reserved words.

Worked example

Start with this query written in one go, lower-case and unbroken:

select u.id, u.name, o.total from users u inner join orders o on o.user_id = u.id where o.total > 100 order by o.total desc

The formatter turns it into:

SELECT
  u.id,
  u.name,
  o.total
FROM
  users u
  INNER JOIN orders o ON o.user_id = u.id
WHERE
  o.total > 100
ORDER BY
  o.total DESC

Every keyword (SELECT, FROM, INNER JOIN, ON, WHERE, ORDER BY, DESC) is now uppercase; the three selected columns each sit on their own two-space-indented line; and the INNER JOIN is tucked under FROM with its ON condition kept inline, which is how most SQL style guides lay out joins.

Your queries never leave the browser

Nothing is uploaded and no history is stored. Formatting is pure local text processing, which matters when a query references private tables, embedded credentials or customer records. Close the tab and there is no trace left.

Frequently asked questions

Does it format every SQL dialect?

It targets the everyday queries of MySQL, PostgreSQL, SQL Server, SQLite and MariaDB: SELECT, INSERT, UPDATE and DELETE with their JOIN, WHERE, GROUP BY and ORDER BY clauses. It is not a full standard parser, so highly engine-specific syntax (complex window functions, nested CTEs, stored procedures) may come out less polished — though the text stays valid.

Does it change what my query means?

No. It only rearranges whitespace, line breaks and keyword casing. The SQL stays functionally identical: same identifiers, same values, same logical order. SQL is case-insensitive for its reserved words, so select and SELECT mean exactly the same thing to the engine.

Why doesn’t it uppercase count or my table name?

Because they are not structural keywords — one is a function and the other an identifier. The formatter only touches the language’s reserved words (SELECT, WHERE, JOIN, and so on). Leaving function, table and column names as you typed them avoids breaking engines that treat identifiers as case-sensitive.

Does it respect text inside quotes?

Yes. Before applying any rule, the tool detects strings wrapped in single quotes, double quotes or backticks and treats each as an untouchable block. A word like from written inside 'some from example text' is neither reformatted nor uppercased.

Related tools