SQL Comment Remover

Strip -- and /* */ comments from SQL while keeping the layout and every string literal exactly as written.

SQL
Without comments
Runs locally in your browser

About the SQL Comment Remover

Comments in a query are useful to the author and noise to everything else: log parsers, query fingerprinting, and drivers that choke on a comment at the end of a line. This tool removes both comment styles while leaving the line structure otherwise intact, so the query stays readable. Quoted strings are skipped character by character, so a literal such as '--not a comment' survives.

Unlike the minifier, it does not collapse whitespace, which makes it the right choice when you want to remove comments before sharing a query but keep it formatted. Blank lines left behind by removed comment lines are collapsed to one.

The scan is text-based and dialect-agnostic. Optimizer hints written as comments, for example Oracle's /*+ INDEX */, are removed too; keep a copy if you rely on them.

How to use

  1. Paste the SQL.
  2. Copy the cleaned query.
  3. Run it through the SQL Formatter if the removed lines left odd spacing.

Common questions

Are optimizer hint comments removed?
Yes, all block comments are removed including hints. Reinsert hints by hand if needed.
What about a # comment in MySQL?
The # style is not removed, since # is valid in other dialects. Replace it with -- first if needed.
Does it preserve indentation?
Yes, only the comment text is removed.