ProviaTools

SQL Formatter

Beautify and format SQL queries.

Loading tool...

Private by design

Your inputs stay in the browser session for this tool run.

Client-side utilities

SQL Formatter runs as a browser utility: Beautify and format SQL queries.

Same-page workflow

Useful for quick checks while coding — no paste into an unknown third-party API.

Free to use

Use SQL Formatter without creating an account or installing software.

Before you rely on the result

Local helper for one task. Read the output before you commit it.

Spot an error? Tell us.

About SQL Formatter

What this tool does

The SQL Formatter makes a one-line or messy SQL query easier to read by uppercasing keywords and starting major clauses on new lines. Paste your query and the formatted version appears below with a copy button.

It is a lightweight tidy-up, not a full SQL parser. For a quick look at a long SELECT with several joins, putting FROM, WHERE, and GROUP BY on their own lines is often all you need.

How to use it

  1. Paste your SQL. Put the query in the SQL input box.
  2. Read the formatted SQL. The output shows the query with keywords uppercased and clauses on separate lines.
  3. Copy the result. Press Copy and paste it into your editor or ticket.

How it works

The query's whitespace is first collapsed to single spaces. A list of common keywords, including SELECT, FROM, WHERE, JOIN, GROUP, ORDER, HAVING, LIMIT, INSERT, UPDATE, DELETE, AND, OR, and CASE, is then converted to uppercase. Clauses such as JOIN, ON, UNION, GROUP BY, ORDER BY, WHERE, and FROM are moved onto new lines.

The formatter does not indent nested queries or align columns, and it does not know which SQL dialect you use. Because it matches words by pattern, a keyword inside a string literal or a column named like a keyword can also be uppercased, and extra spaces inside string literals are collapsed. Review the output before running it against real data.

A worked example

Input select id, name from users where active = 1 order by name limit 10 becomes five lines: SELECT id, name, FROM users, WHERE active = 1, ORDER BY name, and LIMIT 10.

A query with left join orders o on u.id = o.user_id gets its ON condition on its own line. Because the plain JOIN clause is also matched, the word LEFT can end up alone on the line above JOIN orders o, so glance at join lines and merge them by hand if you prefer.

What you get

  • Keyword uppercasing. Common SQL keywords are normalised to capitals.
  • Clause per line. Major clauses such as SELECT, FROM, WHERE, JOIN, ON, GROUP BY, and ORDER BY start on new lines.
  • Whitespace clean-up. Messy spacing and line breaks are collapsed.
  • Copy button. Take the result straight to your editor.

Who it helps

  • Developers. Make queries from logs readable.
  • Analysts. Tidy queries before sharing.
  • Students. See query structure at a glance.
  • Support engineers. Read queries pasted into tickets.

SQL Formatter FAQs

Raw SQL queries generated by frameworks or copied from logs are often packed into a single unreadable line. An SQL Formatter adds consistent line breaks, indents nested conditions, and capitalizes keywords, making complex queries far easier to read, debug, and review.