Utility Hub

SQL Formatter

Format and beautify SQL queries instantly. Choose your dialect and keyword style. All processing happens in your browser — your queries are never sent to a server.

This tool formats SQL for readability only — it does not execute queries. Processed locally in your browser.

Dialect:
Keywords:
Indent:

Tip: Press Ctrl+Enter to format.

What is a SQL Formatter?

A SQL formatter (also called a SQL beautifier) takes compact or hand-written SQL and rewrites it with consistent indentation, line breaks, and keyword casing — making queries far easier to read, review, and debug.

How to use

  • Paste your SQL query into the input area.
  • Choose a dialect — SQL (generic), MySQL, PostgreSQL, or SQLite. The dialect affects keyword recognition and quoting rules.
  • Choose keyword casing — UPPER, lower, or Preserve to keep the original case.
  • Set indent width — 2 or 4 spaces.
  • Click Format SQL or press Ctrl+Enter to format.
  • Click the Copy button to copy the formatted output.

Supported SQL syntax

  • SELECT, FROM, WHERE, ORDER BY, GROUP BY, HAVING
  • JOIN, LEFT JOIN, INNER JOIN, CROSS JOIN
  • INSERT INTO, UPDATE, DELETE FROM
  • UNION, UNION ALL, subqueries, aliases
  • Common SQL functions: COUNT, SUM, AVG, MAX, MIN, COALESCE, CAST, CASE WHEN

Examples

Before: SELECT u.id,u.name,o.total FROM users u LEFT JOIN orders o ON u.id=o.user_id WHERE u.status='active' ORDER BY u.name

After (PostgreSQL, UPPER, 2-space indent):

SELECT
  u.id,
  u.name,
  o.total
FROM
  users u
  LEFT JOIN orders o ON u.id = o.user_id
WHERE
  u.status = 'active'
ORDER BY
  u.name

FAQ

  • Does this execute my SQL? No. This tool only reformats the text. It never connects to a database.
  • Is my SQL sent to a server? No. All formatting is performed locally in your browser using the open-source sql-formatter library.
  • Why does the output look slightly different per dialect? Each SQL dialect has slightly different reserved keywords and quoting conventions. Choosing the correct dialect produces the most accurate output.
  • Can I format multiple queries at once? Yes — paste multiple queries separated by semicolons and they will each be formatted with a blank line between them.

Privacy

Your SQL is processed entirely in the browser. No queries, table names, or any other data are transmitted to any server.