admin@likeapro.dev: ~/sql — zsh

// admin tools · 14

SQL formatter

Turn one-line SQL into readable, consistently indented queries for ten dialects — or minify it back down, without touching strings, quoted names or optimiser hints.

// runs locally — nothing is uploaded

keyword case
output

                                    
                                
FORMAT local only · 0 bytes sent --:--:--

How it works

What it does

Paste SQL and get it back formatted: one clause per line, consistent indentation, keywords in the case you choose. Or flip to --minify to squeeze it onto as few characters as possible for logs, config files or query strings. Formatting uses the open-source sql-formatter library (v15.9.0, MIT licence), served from this site and loaded only when you first format. Nothing is sent anywhere.

How to use it

  1. Pick your database dialect. It matters: quoting, comments, placeholders and some keywords differ between databases.
  2. Paste a query or a whole script. Several statements separated by ; are fine.
  3. Set keyword case, function case, indentation and where AND/OR break, then copy the result.

Dialect differences it handles

PostgreSQL
$$ … $$ and $tag$ dollar-quoted bodies, E'…' escape strings, nested block comments, :: casts, $1 parameters.
MySQL / MariaDB
Backtick identifiers, backslash escapes, # comments, and -- only counting as a comment when followed by a space.
SQL Server
[bracketed] identifiers and @variables.
BigQuery
Backticked `project.dataset.table` names, # comments, double-quoted strings.

How minify stays safe

Minify never parses or rewrites your SQL. It runs a small dialect-aware tokenizer, removes comments, and replaces each run of whitespace with a single space — or with nothing next to ( ) , ;. Strings, quoted identifiers and dollar-quoted bodies are copied byte for byte. Optimiser hints such as /*+ INDEX(t idx) */ and MySQL's /*! … */ are kept, because removing them changes the query plan. The same tokenizer drives the syntax highlighting, and every character is HTML-escaped before display.

FAQ

Is my SQL sent to a server?

No. Both the formatter library and the minifier run in this page. That matters for queries that include table names, customer data or credentials.

Why does formatting fail on my query?

The formatter parses the query, so unusual vendor syntax or a typo can stop it. The error shows the line and column. Try a closer dialect, or use --minify, which never parses.

Does formatting change what the query does?

It only changes whitespace and the case of keywords and functions. Identifiers and string literals are left exactly as written. Keep identifier case in mind on databases where quoted names are case-sensitive.

Can it format stored procedures?

Simple procedure bodies usually work, especially inside PostgreSQL dollar quotes, which are kept as one block. Complex procedural code (loops, exception handlers) is best kept as written.