Format and Minify SQL

Paste any SQL query, or drop a .sql file, and see the beautified and minified versions side by side, updated instantly. Nothing is sent anywhere.

Format and Minify SQL

Drop your SQL file here

Up to 20MB per file. Stays on this device.

Nothing is sent anywhere. Turn off your Wi-Fi and this page still works - try it.

How it works

  1. Drop or choose a .sql file, or paste a query directly into the text box.
  2. The beautified (readable, indented) and minified (single-line) versions both render immediately.
  3. Pick a dialect if you need MySQL backticks, SQL Server brackets, or standard double-quoted identifiers recognized correctly. Copy or download whichever result you need.
Example output

Input

select u.id, u.name from users u join orders o on o.user_id = u.id where o.total > 100 order by u.name

Output (beautified)

SELECT u.id,
  u.name
FROM users u
JOIN orders o
ON o.user_id = u.id
WHERE o.total > 100
ORDER BY u.name

A short query with a join and a filter, beautified into readable, indented form.

Frequently asked questions

Is my SQL sent anywhere?

No. Pasted SQL and uploaded files are both read and reformatted entirely on your device, and nothing is sent to a server. Turn off your Wi-Fi after the page loads and it still works. This page loads 10KB of JavaScript, gzipped - about what your browser's network tab will show for this page's own scripts.

Does this fully understand every SQL dialect (MySQL, PostgreSQL, T-SQL, SQLite, BigQuery, Snowflake)?

Honestly, not as a full grammar - this tool reformats based on recognized keywords and structure rather than parsing SQL as a complete, dialect-specific language (writing a correct parser for even one of these dialects, let alone six, is a genuinely large undertaking, and a subtly wrong parser would be worse than an honest reformatter). What the dialect selector actually changes: which characters are recognized as a quoted identifier - backticks for MySQL/BigQuery, square brackets for SQL Server, double quotes for the rest - so [Order Date] or `user id` is never mistaken for stray punctuation. It does not validate that your SQL is correct, and it does not know about dialect-specific statement forms.

Does the beautified version change what my query does?

No. Every keyword, identifier, string, number, and comment is preserved exactly - only whitespace changes (line breaks, indentation, and spacing), plus keywords are uppercased for readability. A string literal like 'Some, text (here)' is never touched even though it contains characters that look like SQL punctuation.

Why does a function call like COUNT(id) stay on one line instead of being indented like a subquery?

This tool tells the two apart by what immediately follows the opening parenthesis: a real subquery starts with SELECT or WITH and gets its own indented block, while anything else - a function call, a column list, a VALUES list - stays on the same line it started on. That matches how a person would actually want a query laid out: COUNT(id) reads better inline than broken across three lines.

What happens to comments in my query?

The beautified version keeps both -- line comments and /* block */ comments exactly where they were. The minified version removes all comments, the same way any other code minifier does, since a minified query is meant for a machine to run, not a person to read.

Files are processed locally in your browser and never uploaded. Read more on the privacy page.