ToolHarbor

SQL Formatter

Format and beautify SQL queries online. Add proper indentation, uppercase keywords, and improve readability.

Supported SQL Keywords

SELECT, FROM, WHERE, AND, OR, JOIN, LEFT JOIN, RIGHT JOIN, INNER JOIN, ON, GROUP BY, ORDER BY, HAVING, LIMIT, OFFSET, INSERT INTO, VALUES, UPDATE, SET, DELETE FROM, UNION, CASE, WHEN, THEN, ELSE, END, and more.

Features

  • Format SQL with proper indentation
  • Uppercase SQL keywords automatically
  • Minify SQL to remove whitespace
  • Support for common SQL dialects
  • Copy formatted output with one click
  • Works offline - your queries stay private

How to Use

  1. 1Paste your SQL query in the input field
  2. 2Click "Format" to beautify the SQL
  3. 3Adjust the indentation size if needed
  4. 4Use "Minify" to compress the query
  5. 5Copy the formatted result to your clipboard

Examples

Simple SELECT query

Input

SELECT id, name, email FROM users WHERE active = 1 ORDER BY name

Output

SELECT
  id,
  name,
  email
FROM users
WHERE active = 1
ORDER BY name
JOIN query

Input

SELECT u.name, o.total FROM users u INNER JOIN orders o ON u.id = o.user_id WHERE o.status = "completed"

Output

SELECT
  u.name,
  o.total
FROM users u
INNER JOIN orders o
  ON u.id = o.user_id
WHERE o.status = "completed"

What is a SQL Formatter?

SQL (Structured Query Language) is the standard language for interacting with relational databases. SQL queries can become complex with multiple joins, subqueries, and conditions. A SQL formatter transforms messy or minified SQL into a clean, readable format with proper indentation and consistent styling.

Readable SQL is easier to debug, review, and maintain. When queries are properly formatted, you can quickly understand the structure: which tables are being joined, what conditions are applied, and how results are sorted. This is especially important in team environments where multiple developers work with the same queries.

Our SQL formatter applies several transformations: it adds line breaks before major clauses (SELECT, FROM, WHERE, JOIN), indents column lists and conditions, and converts SQL keywords to uppercase. Uppercase keywords are a common convention that makes the SQL structure stand out from table and column names.

The formatter supports standard SQL syntax used by most databases including MySQL, PostgreSQL, SQL Server, SQLite, and Oracle. While each database has dialect-specific features, the core SQL syntax is shared, and this formatter handles the most common patterns effectively.

All formatting happens locally in your browser. Your SQL queries, which may contain sensitive table structures, column names, or data conditions, are never sent to any server. This makes the tool safe for formatting production queries or queries containing confidential business logic.

Frequently Asked Questions

Related Tools