How to Format SQL Online

Format and beautify SQL queries instantly. Free SQL formatter with syntax highlighting, indentation, and support for MySQL, PostgreSQL, and SQLite.

Open SQL Formatter →

Step-by-Step Guide

1

Paste your SQL query

Copy your raw SQL — SELECT statements, JOINs, subqueries, or entire stored procedures — and paste it into the input area. The tool handles any SQL dialect.

2

Click Format

Hit the Format button. The tool adds proper indentation, capitalizes SQL keywords (SELECT, FROM, WHERE), and breaks long lines into readable blocks.

3

Adjust formatting options

Choose your preferred indent size (2 or 4 spaces), keyword case (uppercase or lowercase), and line break style. Toggle options to match your team's SQL style guide.

4

Copy the formatted SQL

Copy the clean, readable SQL back into your editor, documentation, or PR review. Everything runs locally in your browser — your queries stay private.

Try It Now — Free

No signup, no download. Runs entirely in your browser.

Open SQL Formatter

Frequently Asked Questions

Which SQL dialects are supported?
The formatter supports standard SQL, MySQL, PostgreSQL, SQLite, Microsoft SQL Server, and Oracle syntax. Most formatting rules apply universally across dialects.
Is my SQL data safe?
Yes. The formatter runs entirely in your browser using JavaScript. Your queries are never sent to any server — ideal for formatting queries containing sensitive table names or data.
Can it format complex queries with subqueries?
Yes. The formatter handles nested subqueries, CTEs (WITH clauses), CASE expressions, window functions, and multi-table JOINs. Each nesting level gets proper indentation.
Related Reference

SQL Cheat Sheet

View Cheat Sheet →

More Guides