---
title: SQL Formatter: Free Online Tool | Relic
description: Free SQL formatter. Paste a messy query and get clean, indented, readable SQL with keywords aligned. Runs in your browser, nothing uploaded.
canonical: https://relic.space/tools/sql-formatter
source: https://relic.space/llms.txt
---
# SQL Formatter

Paste a messy query and get clean, indented SQL with keywords uppercased and clauses on their own lines. Runs in your browser, nothing uploaded.

Runs entirely in your browser. Nothing you type is uploaded.

Input

Formatted

Formatted SQL appears here…

## A cleaner query in one paste

This **SQL formatter** uppercases the keywords you know (**SELECT**, **FROM**, **WHERE**, the **JOIN** family, **GROUP BY**, **ORDER BY**, **LIMIT** and more), drops each major clause onto its own line, and indents `AND` and `OR` underneath so a long condition is easy to scan. Quoted strings are left untouched, so your literals stay exactly as written, and your comments are preserved too: both `--` line comments and `/* ... */` block comments are pulled out and put back on their own line, so nothing after a comment ever gets dropped. It is a fast convenience formatter rather than a full parser, which is all you usually need to make a query readable. Everything runs in your browser.

## The query you will run again next week

Good queries get reused, then lost in a sea of terminal history. **Relic** keeps an end-to-end encrypted, searchable memory of everything you copy, on every device, for as long as you want. The formatter is free, and that query you just cleaned up is one search away the next time you need it.

## Frequently asked questions

How do I format SQL?+

Paste your query and the formatted version appears next to it: keywords uppercased, each major clause (SELECT, FROM, WHERE, the JOIN family, GROUP BY, ORDER BY, LIMIT) on its own line, and AND, OR, and ON indented under the clause they belong to. Copy the result in one click.

Will formatting change what my query does?+

No. It only adds and removes whitespace and adjusts the case of keywords; it never rewrites the logic. Quoted string literals are left exactly as written, and both line comments (--) and block comments (/\* ... \*/) are preserved, so the query runs the same as before.

Does it work with any SQL dialect?+

Mostly. It is a fast convenience formatter, not a full parser, and it recognizes the common keywords shared across MySQL, PostgreSQL, SQL Server, SQLite, and others. Very dialect-specific or deeply nested syntax may not indent perfectly, but the output stays valid and far more readable than a one-line query.

Why does the formatter uppercase my keywords?+

Uppercasing keywords like SELECT and WHERE is a long-standing SQL convention that makes the structure of a query jump out from the table and column names. Your identifiers and string literals keep their original case.

Is my query uploaded when I format it?+

No. Formatting runs entirely in your browser, so queries containing real table names or embedded values never leave your machine.

You just copied that. What if you never lost it?

**Relic** remembers everything you copy, forever, searchable on every device, and  end-to-end encrypted so only you can read it.

 250 MB free

[Download forWindows](https://relic.space/download/windows)[Download formacOS](https://relic.space/download/macos)[Download forLinux](https://relic.space/download/linux)[Download forAndroid](https://play.google.com/store/apps/details?id=relic.space.app&referrer=utm%5Fsource%3Drelic.space%26utm%5Fmedium%3Dwebsite%26utm%5Fcampaign%3Dcontent)[Download foriPhone](https://apps.apple.com/us/app/relic-clipboard-vault/id6800556025)

More free tools

[JSON Formatterjson formatter](https://relic.space/tools/json-formatter)[Base64 Encode / Decodebase64 decode](https://relic.space/tools/base64)[Diff Checkerdiff checker](https://relic.space/tools/diff-checker)[URL Encode / Decodeurl decoder](https://relic.space/tools/url-encode-decode)[UUID Generatoruuid generator](https://relic.space/tools/uuid-generator)[Epoch Converterepoch converter](https://relic.space/tools/epoch-converter)[All tools](https://relic.space/tools)
