snaptxt.app

SQL Formatter

Beautify, format, and minify SQL for MySQL, PostgreSQL, SQLite, and more. Runs entirely in your browser.

Formatted
Input
Formatted output
SELECT
  u.id,
  u.name,
  u.email,
  count(o.id) AS orders
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.active = TRUE
  AND o.created_at > '2024-01-01'
GROUP BY
  u.id,
  u.name,
  u.email
HAVING
  count(o.id) > 3
ORDER BY
  orders DESC
LIMIT
  20;

How to use it

  1. 1Paste or type your SQL query on the left.
  2. 2Pick your database dialect, then choose Format or Minify.
  3. 3Copy the result — formatting happens entirely in your browser.
  4. 4On Chrome with the Prompt API enabled, hit Explain to get a Gemini Nano walk-through of what the query does, joins, and notable WHERE filters.

Common use cases

  • Clean up a one-line query copied out of application logs.
  • Standardize SQL formatting before committing a migration.
  • Make a complex JOIN readable while debugging a slow query.
  • Minify a query to drop into a single-line config or test fixture.
  • Get a plain-English explanation of an unfamiliar query via on-device AI.

Frequently asked questions

Is my SQL sent to a server?
No. Formatting runs entirely in your browser — your query never leaves your device. Even the optional AI Explain runs on-device via Chrome's Gemini Nano.
Which dialects are supported?
Standard SQL, MySQL, PostgreSQL, SQLite, SQL Server (T-SQL), and BigQuery. Pick the closest match for the most accurate formatting.
Does it validate my SQL?
It formats best-effort and flags input it can't parse, but it isn't a full SQL validator or linter.
What does Minify do with comments and strings?
It removes comments and collapses whitespace while preserving the exact contents of quoted strings.
How does the AI Explain feature work?
It uses Chrome's built-in Prompt API (Gemini Nano), running the model entirely on your device — no API calls to a remote service. The button only appears if your browser supports it (Chrome 138+).