Format SQL Online

Beautify SQL queries for MySQL, PostgreSQL, BigQuery, and more. Instant formatting, zero server requests — your queries stay on your device.

Rules:Smart QuotesConverts curly quotes (“” ‘’) to straight quotes. Always active.Non-Breaking SpacesReplaces non-breaking spaces (U+00A0) with regular spaces. Always active.Line EndingsNormalizes CRLF → LF and trims trailing whitespace per line. Always active.Removes invisible zero-width characters (U+200B, U+200C, U+200D) that silently break string comparisons.Strips the Byte Order Mark (U+FEFF) that causes “invalid character” errors in parsers and editors.Removes soft hyphens (U+00AD) from PDFs that show as garbled characters in code editors.Converts mixed tabs/spaces to a consistent indent width. Click to pick a size.Collapses all line breaks into one continuous paragraph. Great for reflowing PDF or email text.Control blank line density. Click to pick Keep 1 or Remove all.Text never leaves your browser
0 characters

Supported SQL Dialects

Select your database dialect for accurate keyword formatting

MySQL

The world's most popular open-source relational database. Used by WordPress, Shopify, and millions of web apps.

PostgreSQL

Advanced open-source database with JSON support, full-text search, and extensibility. Favored for complex applications.

BigQuery

Google Cloud's serverless data warehouse. SQL dialect for petabyte-scale analytics and ML workflows.

SQLite

Lightweight embedded database used in mobile apps, browsers, IoT devices, and local development.

T-SQL

Microsoft SQL Server and Azure SQL dialect. Used across enterprise .NET and Windows ecosystems.

Standard SQL

ANSI/ISO SQL compatible with any database. Use this when dialect doesn't matter or for generic queries.

How to Format SQL Queries

  1. Paste your SQL query into the text area above. If you're in a different mode, the tool auto-detects SQL and suggests switching.
  2. Select your dialect from the dropdown — MySQL, PostgreSQL, BigQuery, SQLite, T-SQL, or Standard SQL. Toggle “UPPERCASE keywords” on or off.
  3. Copy the formatted result. Click “Copy Clean Text” or press Ctrl+K. You can also download it as a .sql file.

Before and After

Here's a typical query before and after formatting. The input is a single line — the output is structured, indented, and easy to read.

Before (minified)
select u.id,u.name,o.total from users u inner join orders o on u.id=o.user_id where o.status='active' and o.total>100 order by o.total desc
After (formatted)
SELECT
  u.id,
  u.name,
  o.total
FROM
  users u
  INNER JOIN orders o ON u.id = o.user_id
WHERE
  o.status = 'active'
  AND o.total > 100
ORDER BY
  o.total DESC

Why Format SQL?

Unformatted SQL is one of the biggest obstacles to productive code review. A 200-character single-line query hides its logic — the joins, the filter conditions, the grouping, and the ordering are all crammed together. Reviewers have to mentally parse the query before they can evaluate whether it's correct. Formatted SQL makes the structure immediately visible: each clause gets its own line, joins are aligned, and subqueries are indented. This cuts review time dramatically and catches bugs like missing join conditions or incorrect WHERE clauses.

Formatting is equally critical for debugging. When a query returns unexpected results or times out, the first step is understanding what it actually does. A formatted query lets you trace the data flow: which tables are joined, what filters are applied, how results are grouped and sorted. Complex queries with CTEs (WITH clauses), window functions, and nested subqueries are essentially unreadable without proper indentation. The formatter handles all of these structures, giving you a clear view of even the most complex analytics queries.

UPPERCASE Keywords

The convention of uppercasing SQL keywords — SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY — is one of the most widely followed practices in SQL development. It creates a clear visual distinction between the structural keywords that define the query's shape and the user-defined names (tables, columns, aliases) that define its content.

Most SQL style guides recommend uppercase keywords, including Simon Holywell's SQL Style Guide, GitLab's SQL guidelines, and Kickstarter's SQL style guide. The formatter uppercases keywords by default. If your team prefers lowercase keywords, uncheck the “UPPERCASE keywords” option to preserve the original casing.

Privacy & Database Security

SQL queries often contain sensitive information: table names reveal your data model, column names expose what data you collect, and WHERE clauses can contain literal values like user IDs, email addresses, or API keys. Pasting these into an online tool that uploads them to a server is a security risk.

Unformat.online processes all SQL entirely in your browser. The formatting library runs as JavaScript — your queries are never sent over the network, never stored on disk, and never logged. There are no server-side endpoints, no databases, and no analytics on query content. You can verify this by opening your browser's Network tab: zero requests are made during formatting.

This makes Unformat.online safe for production queries, internal analytics, database migrations, and any SQL containing proprietary schema or sensitive data.

Frequently Asked Questions

Are my SQL queries sent to a server?

No. All formatting happens in your browser using JavaScript. Your queries never leave your device. This is critical for queries containing sensitive table names, column values, or business logic.

Which SQL dialects are supported?

Standard SQL (ANSI), MySQL, PostgreSQL, BigQuery, SQLite, and T-SQL (Microsoft SQL Server). Select the dialect from the dropdown above the text area to get dialect-specific keyword recognition and formatting.

Can I format multiple SQL statements at once?

Yes. Separate your statements with semicolons and the formatter will format each one individually, with blank lines between them for readability.

Does formatting change the meaning of my query?

No. Formatting only adds whitespace and line breaks. The actual SQL tokens — keywords, identifiers, operators, and literal values — are never modified. The formatted query is semantically identical to the original.