SQL Minifier

Turn a nicely formatted query into one compact line for a config file, environment variable, log message or JSON payload. Line breaks and extra spaces go, comments are removed (or kept safely as /* */), and strings and quoted names stay exactly as written. Optimizer hints such as /*+ INDEX(...) */ are always kept.

Action

Decides which quotes and comments are recognised.

-- comments become /* */ so they can't swallow the rest of the line. Optimizer hints (/*+ ... */) are always kept.

SQL
Minified SQL

375 characters to 350 (7% shorter). Strings and quoted names are never changed.

Processing runs in your browser. What you type never leaves this device.

Features

  • One line, single spaces

  • Removes -- and /* */ comments, or keeps them safely

  • Keeps optimizer hints (/*+ */ and MySQL /*! */)

  • Never touches strings or quoted names

  • Shows how much shorter the query became

When a one-line query is handy

Config and environment variables

Store a query in a .env file or YAML value without multi-line quoting.

JSON and API payloads

Send a query inside JSON without escaping every line break; [JSON escape](/tools/json-escape) handles the quotes.

Logs and comparisons

Normalise queries to one line before grouping or comparing them.

Minifying safely

Why -- comments need care

A -- comment runs to the end of the line. On a one-line query it would hide everything after it, so when you keep comments they are rewritten as /* */.

Related tools

Make a query readable again with the SQL formatter.

SQL Minifier - FAQ