Language
English English Vietnamese (Tiếng Việt) Vietnamese (Tiếng Việt) Chinese (简体中文) Chinese (简体中文) Portuguese (Brazil) (Português do Brasil) Portuguese (Brazil) (Português do Brasil) Spanish (Español) Spanish (Español) Indonesian (Bahasa Indonesia) Indonesian (Bahasa Indonesia)
SQL Formatter

SQL Formatter

Format and beautify SQL queries with adjustable indentation, keyword casing, and dialect support for MySQL, PostgreSQL, MSSQL, and Oracle.

Format SQL Queries Online

This SQL formatter turns dense, single-line, or inconsistently styled queries into clean, indented SQL in real time — right in your browser. Paste a long SELECT with several joins or a cramped statement copied from a log and the beautified result appears instantly in the right-hand panel, with clauses aligned and keywords cased to your preference.

Built on the sql-formatter library with support for multiple dialects, so the output respects the syntax of the database you actually use.

Common Use Cases

Untangle Long Queries

Break a one-line query with many joins, subqueries, and conditions into a readable, indented structure.

Review & Debug

Make queries from application logs, ORMs, or BI tools easy to read so you can spot logic and performance issues.

Standardize Style

Apply consistent keyword casing and indentation before committing SQL to a repository or sharing it with a team.

How to Beautify SQL

1

Paste Your Query

Type or paste SQL into the Input panel on the left. You can also Upload a .sql file, or click Sample to load an example.

2

See Instant Output

The formatted, syntax-highlighted query appears automatically in the right panel as you type. Line numbers and a live size counter make long scripts easy to navigate.

3

Choose Casing & Dialect

Set the indent (2, 3, 4, 8 spaces or Tab), pick the keyword case (UPPER, lower, or preserve), and select the dialect that matches your database. The output re-formats immediately.

4

Copy or Download

Click Copy to grab the result, or Download to save it as a .sql file. Use Edit to tweak the output by hand before exporting.

Everything runs locally. Your queries are formatted entirely in the browser and are never uploaded to a server — safe even when they contain sensitive table or column names.

Formatting Features & Options

Formatting Options

These controls tailor the output to your team's conventions and your specific database. Each change re-formats the query instantly.

OptionChoicesWhat It Controls
Indent2 · 3 · 4 · 8 spaces · TabIndentation width and character used for clauses and nested expressions.
KeywordsUPPER · lower · PreserveCasing applied to SQL keywords such as SELECT and WHERE.
DialectStandard · MySQL · PostgreSQL · MSSQL · OracleThe SQL flavor used to parse and format dialect-specific syntax.

Supported Dialects

Standard SQL

ANSI SQL formatting for portable queries that are not tied to a specific engine.

MySQL & PostgreSQL

Dialect-aware formatting for the two most popular open-source databases.

MSSQL & Oracle

Support for T-SQL (SQL Server) and PL/SQL (Oracle) syntax.

Built-In Tools

Real-Time Formatting

Output updates as you type, with syntax highlighting and line numbers.

Upload & Download

Load a local .sql file or export the formatted result with one click.

Editable Output

Switch the result panel to edit mode to make manual tweaks before copying.

New to the tool? Click Sample to load a deliberately cramped query and watch it format instantly.

SQL Formatter FAQ

What does an SQL formatter do?

It rewrites a query with consistent indentation, line breaks, and keyword casing so the structure is easy to read — one clause per line, indented subqueries, and aligned joins. It only reshapes layout, not the query itself.

Does formatting change my query's results?

No. The formatter only changes whitespace, indentation, and keyword casing for readability. The database parses the formatted query the same way, so it returns exactly the same rows as the original.

Which SQL dialects are supported?

You can format Standard (ANSI) SQL, MySQL, PostgreSQL, MSSQL (T-SQL), and Oracle (PL/SQL). Pick the dialect that matches your database so dialect-specific syntax is handled correctly.

Can I keep or change my keyword casing?

Yes. Set Keywords to "Preserve" to leave casing untouched, or choose UPPER or lower to normalize every keyword to a single style across the query.

Are my queries sent to a server?

No. All formatting happens locally in your browser. Your SQL is never uploaded, logged, or stored, so it is safe even when queries reference sensitive schema or data.

Can it format multiple statements at once?

Yes. Paste a script containing several statements separated by semicolons and each one is formatted in place, keeping the overall structure of the file intact.

What happens if the SQL has a syntax error?

If the input cannot be parsed for the selected dialect, the tool shows an error message instead of producing broken output. Fix the reported issue, or try a different dialect, and the formatted result reappears.

Indent
Input
Output
Error

Paste code on the left to format

|
Paste your SQL query and get properly indented output instantly as you type.
Choose keyword case: UPPER, lower, or preserve the original.
Select your SQL dialect for dialect-aware formatting.
Everything runs locally in your browser — queries are never uploaded.
Want to learn more? Read documentation →
1/5
Start typing to search...
Searching...
No results found
Try searching with different keywords