SQL Formatter

Format and beautify SQL queries instantly in your browser. Free online SQL formatter that adds indentation for readable queries — no uploads, fully client-side.

Loading calculator…

Results

Formatted SQL
DetailValue
Keywords found

What is this calculator for?

Re-indent and line-break a SQL query on its major clauses so it is easy to read, review, and debug.

How to Use This Calculator

Enter the values below, then press Calculate (or press Enter). The calculator updates your results instantly. Try different values to see how your inputs change the outcome.

  1. SQL to format — enter a value. A typical SQL to format would be Paste your SQL query here….
  2. Review your results — the key output is highlighted, with supporting figures below.

What You'll Need

SQL to format
a value · required

About This Calculator

This SQL formatter breaks your query onto separate lines for each major clause (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, etc.) and applies consistent indentation, with string literals left untouched.

It is designed to make long queries readable at a glance. The result is still valid SQL — the formatter only changes whitespace, never the logic or values.

Formatting runs fully in your browser, so you can tidy production queries without sending them anywhere.

Worked Examples

Example

SELECT u.id, u.name, SUM(o.total) total FROM users u JOIN orders o ON o.user_id = u.id WHERE u.active = 1 GROUP BY u.id, u.name ORDER BY total DESC;

Frequently Asked Questions

Does formatting change what my query does?
No. The formatter only affects whitespace, indentation, and line breaks. Keywords, values, and string literals are preserved exactly, so the query runs identically.
Which SQL dialects are supported?
The formatter handles the common clause keywords used across MySQL, PostgreSQL, SQL Server, and SQLite. Dialect-specific syntax is left as-is.