EasyDeveloper

SQL Formatter

Beautify messy SQL with clause-aware indentation, choose UPPER or lower keywords, and minify a query to a single line.

Local ProcessingYour data stays in your browser. Nothing is uploaded.

SQL is easy to write and hard to read once a query grows past a couple of lines. This formatter re-indents queries with clause awareness: the SELECT, FROM, GROUP BY and ORDER BY keywords sit on their own lines, the items they introduce are indented and comma-aligned, and WHERE conditions break cleanly at each AND or OR. Paste a query you can no longer follow and get back the same query with structure you can scan.

Keyword case is up to you. Switch between UPPER and lower and every keyword in the common set - SELECT, FROM, WHERE, JOIN and the rest - is re-cased in place, while column and table names keep their original spelling, so aliases and quoted identifiers are never touched.

Minify mode squeezes a query down to a single compact line with comments removed, useful when a query has to live in a config file or a one-line logger statement. Everything runs locally in your browser; no query is ever uploaded.

Whether you keep queries in a project, paste them into tickets, or hand them to a colleague, a formatted query is easier to review and easier to diff. The output is deterministic - the same input and settings always produce the same text - so formatting becomes a repeatable part of your workflow rather than a judgment call.

Features

  • Clause-aware indentation for SELECT, FROM, GROUP BY and ORDER BY.
  • WHERE, HAVING and ON conditions break on each AND or OR at one level of indent.
  • UPPER or lower keyword case with identifiers left exactly as written.
  • Minify mode strips comments and compresses whitespace to a single line.
  • Subqueries such as IN (SELECT ...) stay inline and stay readable.
  • Clear error messages with line numbers for unterminated string literals.

How to Use

  1. 1

    Paste the query

    Drop any SELECT, INSERT, UPDATE or DELETE statement into the input box, exactly as it exists in your code.

  2. 2

    Pick your settings

    Choose UPPER or lower keyword case, then select a 2- or 4-space indent for the formatted output.

  3. 3

    Format or minify

    Press Format to beautify, or switch the mode to Minify for a compact single-line version of the same query.

  4. 4

    Copy or download

    Copy the formatted result with one click, or download it as a .sql file ready to save.

Example

Before

select id,name from users where age>18 order by name;

SELECT
  id,
  name
FROM
  users
WHERE age > 18
ORDER BY
  name;

Common Problems

Unterminated string literal

A quote opened earlier and never closed - often a doubled quote inside a string or a stray apostrophe in a text literal. The formatter reports the starting line so the fix is quick.

Quoted identifiers

Backticks, double quotes and prefixed literals are preserved exactly as written. Only known keywords are re-cased, so a column named order or a quoted alias never gets touched.

Subqueries stay inline

WHERE id IN (SELECT ...) is kept on the same line to stay readable. Deeply nested subqueries are not re-indented the way a full parser would, by design - the tool targets day-to-day query tidying.

Casts and operators

PostgreSQL casts like total::numeric and every comparison operator are spaced sensibly, so the output reads the way most teams write it.

Multi-dialect input

The tokenizer accepts the common surface of MySQL, PostgreSQL and SQLite, so a query pasted from any of the three formats without conversion.

Comments

Line comments (-- and #) and block comments are kept in place during formatting. Minify mode removes them, since a minified query is usually for shipping, not reading.

Long condition chains

A long WHERE clause is broken onto separate lines at each AND or OR, so every condition is readable instead of trailing off the edge of the screen.

Spacing around operators

Comparison and arithmetic operators are padded with single spaces (a = b, total * rate), matching the style most teams expect, while cast operators like :: are kept glued to the operand they belong to.

Technical Details

The formatter tokenizes SQL into keywords, identifiers, numbers, strings, operators and comments, then re-emits the token stream with a clause-aware state machine instead of pattern-matching on lines - so a keyword buried inside a subquery or expression is never confused with a top-level clause.

List clauses (SELECT, FROM, GROUP BY, ORDER BY) place their keyword on its own line and indent each comma-separated item by one level; inline clauses (WHERE, HAVING, ON, USING) keep their content on the keyword line and break only at a top-level AND or OR.

Multi-word clauses - GROUP BY, ORDER BY, LEFT OUTER JOIN, UNION ALL - are detected as a single unit, so a join is never split across two lines.

String handling covers single quotes, double quotes, backticks, doubled-quote escapes, backslash escapes and prefixed literals such as N'' and E'', with an unterminated-string error that names the starting line.

Identifiers are emitted verbatim; only a closed set of roughly sixty known keywords is eligible for UPPER or lower casing, which is what keeps aliases, table names and quoted identifiers safe.

The emitter normalizes spacing between tokens: binary operators get a single space on each side, commas and semicolons stay glued to the preceding token, and repeated spaces are never introduced, so the output is stable no matter how sloppy the input was.

Everything runs synchronously in the browser. No query text is transmitted, stored or logged.

Frequently Asked Questions

Which SQL dialects does it understand?

The formatter handles the common surface of MySQL, PostgreSQL and SQLite - joins, subqueries, comments and string syntax that all three share. Exotic dialect extensions are treated as plain identifiers.

Will it change my column names?

No. Only recognized keywords are re-cased. Identifiers, aliases and quoted names are emitted exactly as you wrote them.

Why does SELECT put every column on a new line?

That is the clause-aware style: the keyword sits alone and each comma-separated item gets its own indented line, which is the layout that makes long column lists scannable.

Does minify keep my comments?

No. Minify mode removes comments and compresses whitespace to produce a compact single line for config files or log statements.

Is my query uploaded anywhere?

No. Formatting runs entirely in your browser with JavaScript; nothing is transmitted, stored or logged.

Can it format an INSERT or UPDATE?

Yes - INSERT, UPDATE and DELETE are handled by the same tokenizer, with the SET and VALUES clauses indented appropriately. Stored procedure bodies and triggers are tokenized too, since to the formatter they are just ordinary SQL text.

What happens if my string is unterminated?

You get a message naming the line where the string starts, so you can jump straight to the fix instead of hunting through the query. A stray apostrophe in a text literal or a doubled quote that was never closed is the usual cause.

Data & Privacy

Your data stays in your browser. Nothing is uploaded.

Processing
Local
Upload
None
Server Storage
None
Account
Not required