Guide

SQL Formatter: Readable Queries, No Upload

How SQL formatting works, which keywords it recognises, and why a query with credentials should never be pasted into an upload site.

4 min read Updated Nov 2026

Quick Answer

SQL formatting rewrites a one-line or messy query with uppercase keywords, one major clause per line, and indented lists inside parentheses. The data in string literals and the spelling of identifiers stay the same. Formatting runs in your browser, so the query is never uploaded.

Try the SQL Formatter →

How It Works

The page tokenises your SQL into words, strings, comments, numbers and punctuation. Keywords from everyday Postgres, MySQL and SQLite are uppercased. SELECT, FROM, WHERE, JOIN and ORDER BY each start a new line. A comma breaks a list onto the next line, and parentheses push the indent one level deeper. Therefore a one-line log paste becomes a readable block without changing what the database would run.

Which SQL Dialects Are Supported?

Everyday Postgres, MySQL and SQLite keywords are recognised: SELECT, JOIN variants, GROUP BY, WITH, RETURNING and dollar-quoted strings. Therefore a format sql pass on a typical app query uppercases the right words. Exotic vendor extensions stay as ordinary identifiers.

SQL Formatter Example

For example, paste select u.id, u.name from users u join orders o on o.user_id = u.id where o.total > 100 order by o.created_at desc. The output puts SELECT, FROM, JOIN, WHERE and ORDER BY on their own lines, keeps the identifiers as typed, and leaves the comparison intact. That is the same query, only easier to review. How to pretty-print SQL with joins is the same path: paste the long JOIN, read each ON clause on its own indent, and use the result in a code review.

Pretty Print SQL and Beautify SQL

Use this page as a sql beautifier or sql pretty print pass when a one-line query is hard to read. Whitespace and keyword case are insignificant to the database. A formatter uses that freedom to make structure visible. Comments that start with -- or sit between /* and */ are kept on their own lines, however, so a note that explains a tricky predicate is never deleted. Beautify sql and pretty print sql mean the same layout job here.

SQL Formatter vs Alternatives

An IDE formatter needs a project open and a dialect plugin. SQL formatter vs uploading to a web service is the privacy question: many online formatters post your text to a server so they can run a library there. This page is the middle path: open it, paste, and read the result with no account and no upload. It does not rewrite or optimise the query plan. However, when you need the JSON the query returns formatted too, open the JSON Formatter next. Therefore you stay in the browser for both the SQL and the payload.

Why a Browser-Only Formatter Matters

Production SQL sometimes still contains a password, token or connection string. Any formatter that uploads your text can leave that secret in a log. This page runs entirely in your browser. If a quoted value looks like a password or API key, you also get a warning so it is not the next thing you paste into a gist.

Unclosed Quotes

An odd number of single quotes, double quotes or backticks stops the run with a clear error. The tool does not guess where the string should have ended. Fix the quote and try again.

Common Mistakes

Pasting a query that still contains a live password into an upload formatter is the costly mistake. Expecting the formatter to change the query plan is the other: layout is the only job. Making a long JOIN readable before a code review is the everyday win. Rotate any secret that has already been pasted elsewhere, then format a redacted copy here.

You May Also Need

You may also need

Continue Learning