Skip to content
OddsockLocal
Local
Source text
SQL dialectsql
ReadyRuns in this browser. Nothing is uploaded.

How to use

  1. Paste the statement.
  2. Choose the dialect that matches its quoting.
  3. Read one line. Keywords are uppercase.
  4. Check every quoted string. Internal spaces should match the input.

What is SQL minifier?

The minifier first formats the statement, uppercasing keywords, then collapses whitespace that is not inside a string, a quoted identifier, a dollar-quote or a comment. select 'a b' from tab where id = 1 becomes SELECT 'a b' FROM tab WHERE id = 1. The three spaces between a and b are still there. The spaces around FROM are single spaces.

Read more

That order matters. Comments and quotes are detected on the formatted text, so a comment does not get glued into the next keyword, and a string does not lose its padding. Dialect is the same list as the formatter: sql, postgresql, mysql, sqlite, transactsql, bigquery. Pick the dialect whose quoting matches the statement, or a dollar-quoted body can be mistaken for ordinary text.

This is not a query planner. One line is easier to drop into a log or a curl body. The formatter is where you read the statement. Neither page talks to a database.

Use cases

  • A query has to travel in a JSON string and you want one line without losing the spaces inside 'a b'.
  • Keywords should read SELECT and FROM after the collapse, matching the formatter’s case.
  • A dollar-quoted PostgreSQL body must stay intact, so the dialect has to be postgresql.
  • You are checking that a comment does not get smashed against the next word.

One line, string unchanged

Dialect sql. select 'a b' from tab where id = 1

SELECT 'a b' FROM tab WHERE id = 1

Why use Oddsock

The spaces inside the quotes are the whole test. Minifying by deleting every run of spaces would change the value.

Related tools

Using this tool

Strings are copied through. Only whitespace outside strings, identifiers, dollar quotes and comments is collapsed.