TidySQL

No. 001 — entry: one messy query

SQL formatter that keeps your queries in order

Paste a one-line query from a log or an ORM and get clean, indented SQL for MySQL, PostgreSQL, SQLite or SQL Server — or squeeze it back into one line. It all runs in your browser.

Query ledger

form TS-1 · processed locally
Debit · your SQL0 chars
Credit · formatted
Lines: 0 · Chars: 0Balance: —

Why TidySQL

  1. 001

    Five dialects, one parser

    Standard SQL, MySQL, PostgreSQL, SQLite and T-SQL each have their own quoting and operators. Pick the dialect and backticks, dollar-quoted strings, square-bracket names and :: casts are read correctly.

  2. 002

    Your house style

    Uppercase, lowercase or untouched keywords; two spaces, four spaces or tabs; commas at the end of a line or at the start of the next. Every change re-formats the query instantly.

  3. 003

    Minify for one-liners

    Strip comments and extra whitespace to fit a query into a config value, a log line or a shell command. String literals and quoted identifiers are left exactly as written.

  4. 004

    Nothing leaves the page

    The formatter is bundled into the page. Queries with table names, customer IDs or credentials in comments are never sent anywhere, and the tool keeps working offline.

About TidySQL

TidySQL is a free online SQL formatter and beautifier. It takes the queries you actually meet at work — a statement copied from a slow-query log, the output of an ORM, a report someone wrote in a single line — and lays them out so each clause starts on its own line, joins and conditions are indented under the clause they belong to, and the column list reads top to bottom. The formatting engine is the open-source sql-formatter library, so the result is stable and predictable rather than a guess based on regular expressions.

Formatting matters most when SQL is read by people: in code review, in a migration file, in a runbook or a ticket. A consistent layout makes a missing join condition or a wrong GROUP BY column visible at a glance. The opposite direction is useful too — the minifier turns a long query into one compact line for environment variables, JSON configs or a psql -c command. Both work entirely in your browser; nothing you paste is uploaded or stored.

How it works

  1. 1.Paste a query or load the sample.
  2. 2.Choose the dialect, keyword case, indent and comma style.
  3. 3.Press Format or Minify, then copy or download the .sql file.

Guides & articles

Plain-language explainers on the problem this tool solves.

Frequently asked questions

Is my SQL uploaded to a server?+

No. The formatter and the minifier are bundled into the page and run in your browser. Your queries are never sent over the network or stored, so it is safe to paste production SQL with real table names.

Which SQL dialects are supported?+

Standard SQL, MySQL, PostgreSQL, SQLite and T-SQL (Microsoft SQL Server). The dialect decides how quotes, comments, operators such as :: or @variables, and dialect-only keywords are recognised.

Does formatting change what my query does?+

No. Only whitespace, line breaks and, if you choose, the case of keywords change. Identifiers, string literals and comments keep their exact content, so the database runs the same statement.

Why do I get a parse error?+

Usually the selected dialect does not match the query: backticks need MySQL, square-bracket names need T-SQL, $$ strings need PostgreSQL. Unfinished statements and template placeholders like {{name}} can also fail. Switch the dialect or fix the line shown in the message.

What does the comma style option do?+

Trailing puts the comma at the end of each column line, the common default. Leading moves it to the start of the next line, so commenting out or adding the last column touches only one line and diffs stay small.

What does the minifier remove?+

Line breaks, indentation, repeated spaces and both -- and /* */ comments. Spaces are kept where removing them would merge two words, and everything inside quotes, brackets or dollar-quoted strings is copied unchanged.

Can I format several statements at once?+

Yes. Paste a whole script with statements separated by semicolons; each one is formatted and separated by a blank line. This works well for migration files and seed scripts.

Is TidySQL free, and is there a size limit?+

It is free with no account. There is no fixed limit; scripts of several thousand lines format in well under a second on a laptop, and the only ceiling is your browser's memory.