SQL Formatter

Format and beautify SQL queries across multiple database dialects.

How to Use SQL Formatter

  1. Paste your SQL.
  2. Choose your database dialect.
  3. Click Format SQL.
  4. Copy the formatted query.

What formatting does

Each clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY) starts on its own line, columns and conditions are indented two spaces, keywords are converted to uppercase, and multiple queries are separated by blank lines. Only layout and keyword case change; your table names, values and logic stay exactly the same.

The tool uses the open-source sql-formatter library. Picking the right dialect helps it understand syntax specific to your database, such as backtick-quoted names in MySQL or square brackets in SQL Server.

Tips for SQL that stays readable

Formatting helps most when a query gets long. Putting one column per line makes changes easy to spot in code review, short table aliases (o for orders, c for customers) cut repetition, and breaking a large query into named WITH blocks (CTEs) often makes it clearer than nesting subqueries.

The tool uses two-space indentation and uppercase keywords, which is a common convention in teams. Keeping the same style everywhere matters more than which style you pick.

Key Features & Practical Use Cases

  • Making a long one-line query from logs or an ORM readable.
  • Tidying SQL before putting it in a code review, ticket or documentation.
  • Formatting several queries in one go with clear gaps between them.

Frequently Asked Questions

Does it check whether my SQL is valid?

Not fully. It formats what it can parse and shows an error if it can't, but it doesn't check tables or run the query.

Will it change my query results?

No. Only whitespace and keyword capitals change.

Can I keep lowercase keywords?

Not at the moment; keywords are always uppercased.

Is my SQL uploaded?

No. It's formatted in your browser, so it's safe for queries with real table names.

About OneClickly

OneClickly is a set of 119 free tools for PDFs, images, text, everyday math and code. They run in your browser, so the files and text you work with stay on your device.

Related Tools