SQL comment remover

Remove comments from
SQL code.

Remove comments from SQL queries and migration files online. Strips `--` line comments and `/* */` blocks while preserving string literals and identifier quoting.

Free, no signup Runs in your browser Instant, no upload Works on .sql files

Before and after

Real-world SQL code on the left. The same code with every comment removed on the right.

sql-input.sql
-- Migration: add 'archived' flag to orders table
-- Author: ops team

/* Add the column with a safe default. */
ALTER TABLE orders
    ADD COLUMN archived BOOLEAN DEFAULT FALSE NOT NULL; -- backfilled false

-- Backfill existing data
UPDATE orders
   SET archived = TRUE
 WHERE created_at < '2024-01-01' -- old orders only
   AND status = 'closed';

/* Verify count */
SELECT COUNT(*) FROM orders WHERE archived = TRUE; -- sanity
sql-output.sqlcleaned
ALTER TABLE orders
    ADD COLUMN archived BOOLEAN DEFAULT FALSE NOT NULL;

UPDATE orders
   SET archived = TRUE
 WHERE created_at < '2024-01-01'
   AND status = 'closed';

SELECT COUNT(*) FROM orders WHERE archived = TRUE;
Why use it

Built for SQL specifically.

Long-form SQL, schema migrations, ETL pipelines, reporting queries, is heavy with `-- explanation` lines. When debugging a query plan or comparing two versions in a code review, removing the comment noise lets you focus on the structure. Uncommenter handles both `-- line` and `/* block */` styles and never disturbs string literals containing dashes or asterisks.

  • -- line comments removed
  • /* */ block comments removed
  • Single-quoted string literals preserved
  • Identifier quoting ("name" or `name`) preserved
  • Auto-detected from .sql files
How it works

Strip comments in 30 seconds.

  1. 1

    Open the tool

    Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.

  2. 2

    Paste your SQL code

    Drop your .sql file in, or paste code into the editor. Auto-detection picks up SQL from the extension or file content.

  3. 3

    Click 'Remove Comments'

    The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.

  4. 4

    Copy or download

    Grab the cleaned output. Your code never left your browser.

FAQ

SQL questions, answered.

Does it handle string literals with dashes?

+

Yes. SQL strings are single-quoted, and the parser tracks string state, so 'a -- string' is left alone.

What dialects are supported?

+

All standard SQL dialects, PostgreSQL, MySQL, SQLite, MSSQL, Oracle, BigQuery, Snowflake, share the same comment syntax (-- and /* */), so the same engine works for all of them.

Will it keep doc-style headers?

+

Headers using -- or /* */ are removed by default. If you want to preserve a license or migration metadata block, add it back via your build tool after stripping.

Other languages

Working in something else?

Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.

Try it on your SQL code now.

Free forever. No signup. No upload. Runs entirely in your browser.

Open uncommenter