Skip to main content
Toolsbase Logo

SQL Formatter

Format, minify, and syntax highlight SQL queries. Supports MySQL, PostgreSQL, SQL Server, Oracle, and SQLite.

Last updated:

How to Use

Expand how to use
  1. 1

    Enter your SQL

    Type or paste your SQL query into the text area above.

  2. 2

    Configure options

    Select the SQL dialect (MySQL, PostgreSQL, etc.), indentation style, and keyword case preference.

  3. 3

    Format and copy

    Click 'Format' for readable output or 'Minify' to compress into a single line. Copy the result to use.

SQL Input

Output

Result will appear here

About SQL Formatter

SQL Formatter beautifies and minifies SQL queries with support for five major database dialects: MySQL, PostgreSQL, SQL Server, Oracle, and SQLite. Paste minified ORM-generated SQL from Sequelize, Hibernate, or SQLAlchemy, or complex multi-table joins, and get clean, properly indented queries ready for code review, documentation, or debugging. Choose between 2-space, 4-space, or tab indentation styles, and convert keywords to uppercase or lowercase to match your team's conventions. Syntax highlighting provides visual structure verification. Minify mode compresses queries to a single line for embedding in application code or logging configurations.

Key Features

  • Choose indentation style (2 spaces/4 spaces/tabs) for readable formatting
  • Minify to remove whitespace and newlines, compressing to a single line
  • Support for 5 SQL dialects (MySQL, PostgreSQL, SQL Server, Oracle, SQLite)
  • Keyword case conversion options (uppercase/lowercase)
  • Syntax highlighting for visual structure verification

Common Use Cases

  • Format ORM-generated SQL (Sequelize, Hibernate, SQLAlchemy) for debugging
  • Beautify queries from database logs or slow query logs
  • Prepare SQL for code review or pull request comments
  • Minify SQL for embedding in application config files
  • Standardize SQL style across a team or codebase

Frequently Asked Questions

How do SQL dialects affect formatting?

Each database has specific keywords and syntax. For example, MySQL's "LIMIT" vs SQL Server's "TOP". Selecting the correct dialect ensures optimal formatting according to each syntax.

What is keyword case conversion?

A feature that unifies SQL keywords (SELECT, FROM, WHERE, etc.) to uppercase or lowercase. Choosing "Preserve" keeps the original case. Select according to your team's coding conventions.

What's the difference between Format and Minify?

Format adds indentation and line breaks to make SQL human-readable. Minify does the opposite — it removes unnecessary whitespace and newlines, compressing everything to a single line. Minify is useful for embedding SQL in config files or comparing queries programmatically.

Can SQL with syntax errors be formatted?

Basic formatting is possible, but results may not be as expected. If there are syntax errors, we recommend fixing them before formatting.

Is my SQL input sent to a server?

No. Formatting and minification are performed locally in your browser using the sql-formatter library. You can safely paste queries containing table names, column names, or any other schema details you would not want transmitted externally.