# SQL Formatter

> Format SQL with clean indentation and keyword casing, or minify it to one line. Handles subqueries, JOINs, comments and strings. Choose 2 or 4 space indent.

- Page: https://mondaytool.com/tools/sql-formatter
- Category: developer-tools
- Price: free, no sign-up. Most tools run in the browser, so input is not uploaded.
- Use it: open https://mondaytool.com/tools/sql-formatter. It is an interactive web page; this file is its documentation.

Last updated: 16 October 2026

## Format and minify SQL queries

This **SQL formatter** turns a messy one-line query into readable, indented SQL. It can also do the opposite and minify a query into a single line. You choose the indent size and whether keywords are upper or lower case.

## How to use it

1. Paste your query into **SQL Input**. A sample query is loaded to start with.
2. Choose **Format** or **Minify**.
3. For Format, pick an **Indent** of 2 or 4 spaces and switch **Uppercase keywords** on or off.
4. Click **Format SQL** (or **Minify SQL**), then **Copy** the output.

## How it works

The tool splits your SQL into tokens: keywords, identifiers, strings, numbers, comments and punctuation. In Format mode, clause keywords such as SELECT, FROM, WHERE, JOIN, GROUP BY and ORDER BY start a new line. AND and OR go on indented lines, and each comma in a clause starts a new line. A subquery in brackets is indented one level deeper. Other reserved words like NULL, IN or DISTINCT only change case.

Minify removes comments and collapses whitespace between tokens. String literals and quoted identifiers are kept exactly as written.

## What it recognises

- Single-line (`--`) and block (`/* */`) comments.
- Strings in single quotes, including N'', E'', X'' and B'' prefixes.
- Quoted identifiers in "double quotes", backticks and [square brackets].
- Multi-character operators such as `>=`, `<>`, `::` and `->>`, and parameters like `$1`, `@name` and `:name`.

## Assumptions and limits

- The formatter is not tied to one dialect and does not check that your SQL is valid. It reshapes text only.
- Longer constructs such as CASE ... END and window functions are kept on the line they start on, not broken up.
- Format mode does not remove comments. Only Minify does.
- Click the button after changing mode or options. The output does not refresh on its own.
- The text is processed in your browser.

## Frequently asked questions

### Does formatting change what my query does?

It only changes whitespace and keyword case. Strings and quoted identifiers stay as written. Still, review the output before you run it on important data.

### Can I keep my keywords lowercase?

Yes. Turn off Uppercase keywords before you click Format SQL, and keywords come out in lowercase.

### Why would I minify SQL?

A one-line query is easier to paste into a log message, config value or code string. Minify also strips comments, so check you do not need them first.
