Diese Seite ist noch nicht auf Deutsch verfügbar, daher zeigen wir die englische Version.

SQL Formatter & Beautifier

Paste a query — or a whole migration — and get readable SQL with one clause per line, aligned joins and consistent keyword case, using the grammar of your database.

Aktualisiert am
 
Formatted SQL
 

Deine Daten verlassen nie deinen Computer. Die Verarbeitung erfolgt zu 100 % lokal im Browser.

So nutzt du: SQL Formatter

  1. Paste one or more SQL statements into Input SQL (or open a .sql file).
  2. Select your dialect — this matters for things like backtick identifiers in MySQL, :: casts in PostgreSQL or TOP in SQL Server.
  3. Choose keyword case and indentation. The formatted query updates as you type.
  4. Copy the result or download it as query.sql.

What does a SQL formatter do?

SQL is whitespace-insensitive, so queries generated by ORMs, logged by a database or written in a hurry often end up on one enormous line. A SQL formatter parses the statement and re-prints it with each major clause — SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY — starting a new line, column lists indented underneath and sub-queries nested one level deeper. That makes it far easier to spot a missing join condition, a misplaced OR or a column you forgot to group by.

Example

select u.id, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.active = 1 group by u.id

becomes

SELECT
  u.id,
  count(o.id) AS orders
FROM
  users u
  LEFT JOIN orders o ON o.user_id = u.id
WHERE
  u.active = 1
GROUP BY
  u.id

Why the dialect setting matters

Every database extends SQL differently. Choosing the right dialect lets the formatter recognize vendor keywords and syntax instead of treating them as errors:

DialectExamples it understands
MySQL / MariaDB`backtick` identifiers, LIMIT 10, 20, ON DUPLICATE KEY UPDATE
PostgreSQL:: casts, $1 parameters, RETURNING, dollar-quoted function bodies
SQL Server (T-SQL)[bracketed] names, TOP (10), @variables, GO batches
BigQuerySTRUCT/ARRAY types, backtick project.dataset.table paths, QUALIFY
Oracle PL/SQL:bind variables, CONNECT BY, q'[…]' strings

If a query fails with a parse error, the most common cause is a dialect mismatch — try the database you actually run. The formatter is built on the open-source sql-formatter library and runs entirely in your browser, so production queries containing customer data never leave your machine.

Keyword case: upper or lower?

UPPERCASE keywords are the traditional convention and make the query structure stand out from table and column names; many modern teams prefer lowercase because it is easier to type and read. Pick one and stay consistent — linters such as SQLFluff can enforce it in CI. The Functions option controls built-ins like count() or coalesce() separately.

Comparing two versions of a query? Paste them into the Diff Checker. Exported results as JSON? Turn them into a spreadsheet with JSON to CSV.

Auch gesucht als: sql beautifier, format sql, sql pretty print, sql query formatter, mysql formatter, postgresql formatter, t-sql formatter, bigquery formatter.

Passende Tools zu: SQL Formatter

  • JSON Formatierer — Füge JSON ein, um es zu formatieren, zu minifizieren oder zu prüfen.
  • CSV to JSON — Paste CSV or TSV and get a JSON array of objects.
  • JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.
  • HTML Formatter — Paste minified or messy markup and get clean, consistently indented HTML — including embedded <style> and <script> blocks.

Häufige Fragen

Does the formatter change what my query does?
No. Only whitespace and the letter case of keywords (and functions, if you choose) change. Identifiers, string literals and the order of everything stay the same.
Why do I get a parse error?
The formatter has to understand the SQL to lay it out. Errors usually mean the wrong dialect is selected or the statement uses syntax that dialect doesn’t support — template placeholders like {{ var }} can also confuse it.
Can I format several statements at once?
Yes. Separate statements with semicolons; each is formatted and separated by one or two blank lines depending on the “Between queries” setting.
Is it safe to paste production queries?
Yes. The formatting runs in your browser with JavaScript and nothing is sent to our server, so values in your WHERE clauses stay private.
Are stored procedures and DDL supported?
CREATE TABLE, ALTER, INSERT, CTEs (WITH) and window functions are fully supported. Procedural blocks (PL/pgSQL, T-SQL control flow) are formatted on a best-effort basis.
Kann ich SQL Formatter als Web-App installieren und offline nutzen?
Ja. SQL Formatter ist eine installierbare Web-App (PWA) – sie wird über Ihren Browser installiert und nicht aus einem App-Store heruntergeladen. Klicken Sie oben auf dieser Seite in Chrome oder Edge (Windows, macOS, Linux, ChromeOS) auf „App installieren“ oder verwenden Sie auf Android-Geräten „Teilen“ → „Zum Startbildschirm hinzufügen“ auf dem iPhone und iPad bzw. „Datei“ → „Zum Dock hinzufügen“ in Safari 17+ auf einem Mac. Die App öffnet sich dann in einem eigenen Fenster mit einem eigenen Symbol, und da sie vollständig in Ihrem Browser ausgeführt wird, funktioniert sie auch offline. Firefox auf dem Desktop kann keine Web-Apps installieren. So funktioniert die Installation.

Ähnliche Tools