SQL Formatter

Paste a SQL query and instantly get a clean, indented version with capitalised keywords.

Features

Uppercase keywords
Multiple SQL dialects
Indentation control

How to Use

1. Paste your SQL query into the input.

2. Pick a SQL dialect if needed.

3. Click Format and copy the result.

About this tool

Queries copied from logs, ORMs or monitoring tools usually arrive as one long line, which makes joins and conditions hard to follow. This formatter tokenises the SQL, puts major clauses such as SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY and LIMIT on their own lines, indents the parts beneath them, and writes keywords in uppercase so they stand apart from table and column names. Strings, quoted identifiers and comments are kept intact. It works on standard SQL syntax shared by MySQL, PostgreSQL, SQLite, SQL Server and others, and does not need a database connection. Formatting is cosmetic: it does not validate the query or change its meaning, so run it against your database to check for errors.

Frequently Asked Questions

Which SQL dialects are supported?
The formatter recognises standard SQL keywords, so queries written for MySQL, PostgreSQL, SQLite, SQL Server and Oracle all format well. Vendor-specific syntax is kept as written, even if it is not specially indented.
Will formatting change the result of my query?
No. Only whitespace, line breaks and keyword letter case change. Strings, identifiers and comments are preserved, and SQL keywords are not case-sensitive, so the query returns the same result.
Does it check my SQL for syntax errors?
No. The tool formats without connecting to a database or parsing the full grammar. A misspelled column or missing comma is formatted like valid SQL, so test the query in your database or editor.
Why are keywords converted to uppercase?
Uppercase keywords are a widely used convention that separates SQL commands from table and column names at a glance. Databases treat SELECT and select identically.
Is it safe to paste queries containing real data?
Formatting runs in your browser and the query is not sent anywhere. As a general habit, still remove passwords, tokens and personal data from queries before sharing them with other people.

Related Tools