DevToolCase
Sign in Sign in

Minify SQL

Put an SQL query on a single line: comments and extra white space removed, strings and quoted names left untouched.

Share this result

Encrypted in your browser. The key stays in the link, after “#”: only the people you give it to can read it, not even DevToolCase.

The link works for

Sign in for longer links or links without expiry, and to find them in your account.

Runs entirely in your browser: nothing you type is sent or stored.

Why minify SQL?

A query on a single line fits where line breaks are a problem: a string in source code, a log line, a CSV cell, a command-line argument or a configuration value.

What minifying keeps and removes

  • Line breaks, tabs and repeated spaces become a single space, removed next to parentheses and commas.
  • Comments are removed: -- … up to the end of the line, and /* … */. Without line breaks, a -- comment would swallow the rest of the query.
  • Optimizer hints (/*+ INDEX(t idx) */) and MySQL executable comments (/*! … */) are kept: they change how the query runs.
  • Strings and quoted names are left untouched, spaces and line breaks included: 'New York' stays 'New York'.

Why the dialect still matters

To leave strings untouched, the minifier must know where they end, and dialects differ: MySQL escapes a quote with a backslash ('it\'s'), standard SQL doubles it ('it''s'); MySQL treats # as a comment, PostgreSQL as an operator. An unclosed string or comment is reported with its line.

To read a minified query again, format it.

Add this browser’s favorites to your account?

This browser has 0 favorites that your account does not have:

Either way, this browser keeps its favorites: you find them again after signing out.