# SQL Formatter

> Online SQL formatter and beautifier: indent queries, uppercase keywords or minify to one line. Works with MySQL, PostgreSQL, SQL Server and SQLite. Free, in your browser.

Source: https://widgetpantry.com/en/sql-formatter · Türkçe: https://widgetpantry.com/tr/sql-formatlayici

Paste a messy or one-line SQL query: SELECT, FROM, WHERE and the other clauses go on their own lines, columns and conditions line up, and subqueries are indented. Keywords can be upper- or lower-cased. Your query never leaves your browser.

Runs in your browser: files and text are not uploaded. [Use the tool](https://widgetpantry.com/en/sql-formatter)

## How to use it

1. Paste your SQL query on the left.
2. Choose keyword case and indent width, then press Format.
3. Copy the formatted query, or use Minify for a single line.

## Why format SQL?

A long query on one line is hard to follow: it is easy to miss which tables are joined or which condition filters what. The formatter puts each clause (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY, LIMIT) on a new line, lists columns and AND/OR conditions one per line, and indents subqueries inside their parentheses.

Only whitespace and keyword case change: strings ('…'), quoted names ("…", `…`, […]) and comments stay exactly as written, so the query means the same thing. Several statements separated by semicolons get a blank line between them.

Minify puts the query on one line and removes comments (a -- comment would otherwise swallow the rest of the line). The tool understands the syntax shared by MySQL, PostgreSQL, SQL Server, SQLite and Oracle; database-specific commands pass through unchanged.

## Frequently asked questions

### Is my query validated?

No. The tool does not run the query or check its grammar; it only warns about an unclosed quote or comment. Still test the formatted query on your database.

### Which databases does it work with?

It understands the common syntax of MySQL, MariaDB, PostgreSQL, SQL Server, SQLite and Oracle. Parameters (?, :name, @name, $1) and PostgreSQL's :: casts are kept.

### Will my table and column names change case?

No. Only keywords such as SELECT, FROM and AND change case; names and strings stay as they are. "As written" changes nothing.

### Is my query sent anywhere?

No. Formatting runs in your browser; the query is not uploaded or stored.

## Related tools

- [JSON Formatter](https://widgetpantry.com/en/json-formatter): Online JSON formatter and validator: pretty-print, validate and minify JSON. Line and column for errors, 2/4-space or tab indentation, one-click copy.
- [XML Formatter](https://widgetpantry.com/en/xml-formatter): XML formatter and validator: pretty print with indentation, minify, and find unclosed or mismatched tags by line and column. Your XML stays in your browser.
- [Case Converter](https://widgetpantry.com/en/case-converter): Case converter: upper, lower, title and sentence case, plus camelCase, PascalCase, snake_case, kebab-case and CONSTANT_CASE for code. Free, runs in your browser.
