Skip to content

SQL Formatter

Format messy SQL into clean, indented queries for PostgreSQL, MySQL, SQL Server, SQLite, Oracle, BigQuery and more. Free and runs in your browser.

Runs in your browser. Nothing is uploaded.

About the SQL Formatter

SQL copied from logs, ORMs or monitoring tools usually arrives as one long line, which is hard to read and harder to debug. This formatter puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY…) on its own line and indents subqueries, so the query's structure is obvious at a glance.

It understands the syntax of popular databases, including PostgreSQL, MySQL, SQL Server, SQLite, Oracle, BigQuery and Snowflake, and can convert keywords to upper or lower case. Queries often contain table names and data you'd rather not share, so formatting runs in your browser.

How to use it

  1. Paste your query into “Your SQL”, or press “Load sample”.
  2. Pick your database dialect so its specific syntax is recognised.
  3. Choose keyword case and indentation.
  4. Press “Format SQL”, then copy the result or download it as a .sql file.

Examples

One-liner from a log

select id,name from users where active=1 order by name becomes a clean, multi-line query with each clause aligned.

Consistent keyword case

Mixed “Select … from … WHERE” becomes uniformly uppercase (or lowercase) for code reviews and style guides.

Several statements

Multiple queries separated by semicolons are formatted together, with a blank line between each.

Limitations

  • Formatting only changes whitespace and keyword case. It doesn't check that your query is correct or will run.
  • If a query uses syntax specific to one database, choose that dialect, or the formatter may not be able to parse it.
  • Comments are kept, but their position may shift slightly.
  • Stored procedures with complex procedural code may not format perfectly.

Frequently asked questions

Does formatting change what my query does?

No. Only spacing, line breaks and keyword case change. Table names, values and logic are untouched.

Why do I get a parse error?

The query probably uses syntax from a different database. For example, backtick-quoted names are MySQL and square brackets are SQL Server. Select the matching dialect and try again.

Should SQL keywords be uppercase?

It's a convention, not a requirement: SQL keywords are case-insensitive. Uppercase keywords are the most common style because they stand out from table and column names.

Is my query sent to a server?

No. The formatter runs in your browser, so table names, values and other details in your SQL stay on your device.

Related tools