SQL Minifier

Collapse SQL to a single line for embedding in code or config.

Database Runs in your browser
SQL
Single-line SQL

Nothing minified yet

Paste formatted SQL to collapse it onto one line for embedding in application code.

Runs entirely in your browser. Your data isn't uploaded — this page makes no network request with anything you type, which you can verify in your browser's network tab. How this works.

What is the SQL Minifier?

The reverse operation: collapse a formatted query into a single line for embedding in application code, a migration string, a JSON config or a log line. Comments go, runs of whitespace become single spaces, and the statement stays exactly equivalent.

How to use it

  1. Paste the formatted SQL.
  2. Choose whether to strip comments and whether to keep the trailing semicolon.
  3. Press Minify (or Ctrl/Cmd + Enter), then copy the single-line result.

Example

A formatted query collapsed for embedding in code.

Input
SELECT id
  -- only active rows
  FROM users
 WHERE active = true;
Result
SELECT id FROM users WHERE active = true;

Features

  • Collapses all insignificant whitespace to single spaces
  • Removes line (--) and block (/* */) comments, optionally keeping hints
  • Preserves string literals and quoted identifiers byte for byte
  • Before/after character counts

Frequently asked questions

Are optimiser hints removed?
Only if you ask. MySQL and Oracle carry hints inside /*+ ... */ comments, which are semantically meaningful, so they are preserved by default.
Should I really put SQL on one line in my code?
Usually not — a multi-line string or a .sql file is far more maintainable. Minifying is for the cases where the query has to be a single-line value, such as a config field or a structured log.
Esc

Loading the catalog…