🔒 Runs in your browser — nothing is uploaded✓ Free, no signup
SQL Formatter — Beautify SQL Queries Online
Turn long one-line SQL into readable, indented queries. Choose your database dialect, indentation and keyword case — or minify SQL back to one line.
0 characters
When should you use the SQL Formatter?
- Reading a long query copied from logs, an ORM or a slow-query report
- Cleaning up SQL before a code review or putting it in documentation
- Minifying SQL to embed it in a config file or a single log line
How to use the SQL Formatter
- 1
Paste your SQL
Paste one or more statements into the input editor, or click Load sample.
- 2
Choose the dialect
Select your database so dialect-specific syntax such as T-SQL brackets or PostgreSQL :: casts is understood.
- 3
Set indentation and keyword case
Pick 2 spaces, 4 spaces or tabs, and whether keywords should be UPPERCASE, lowercase or kept as typed.
- 4
Format or minify, then copy
Click Format SQL for readable output or Minify for a single line, then use Copy Output.
Examples
One-line query to readable SQL
Before
select id, name from users where status = 'active' and age > 18 order by name
After
SELECT id, name FROM users WHERE status = 'active' AND age > 18 ORDER BY name
Common errors and how to fix them
Parse error at token- The selected dialect does not recognise some syntax. Switch to your actual database (e.g. PostgreSQL or SQL Server) and format again.
Template placeholders like {{id}} or :name break formatting- Replace them with a literal value or ? before formatting, then put the placeholders back.
Keywords used as column names become uppercase- Quote the identifier ("order", `order` or [order]) or set Keywords to 'Keep as typed'.
More from Code Formatters & Minifiers
Free tools that run in your browser — no signup, nothing uploaded.
CSS Minifier & Compressor
Optimize CSS by removing whitespace and comments to accelerate page load time.
JS Minifier & Compressor
Compress JavaScript to improve website speed and performance.
XML Formatter & Validator
Format, validate and minify XML, with errors shown by line and column.
HTML Formatter & Beautifier
Beautify or minify HTML with clean, consistent indentation.
Markdown Editor & Preview
Write Markdown with a live preview and copy the HTML.
HTML to JSX Converter
Convert HTML to valid React JSX — className, style objects and more.
SVG to React Component
Turn SVG markup into a React component with camelCase attributes.
HTML to Markdown Converter
Convert HTML to clean Markdown, including tables and code blocks.
GraphQL Formatter
Format GraphQL queries, mutations and schemas with Prettier.
SQL Formatter FAQ
Standard SQL, MySQL, MariaDB, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle PL/SQL, BigQuery, Snowflake, Redshift and Spark SQL. Pick the one that matches your database so dialect-specific syntax is recognised.
No. Only whitespace, line breaks and keyword case change. Table names, column names, string values and the query logic stay exactly the same.
SQL is case-insensitive for keywords, so it is a style choice. Uppercase keywords (SELECT, FROM, WHERE) are the most common convention because they stand out from table and column names.
The formatter could not understand part of the query. Usually the wrong dialect is selected (e.g. T-SQL brackets or PostgreSQL :: casts under Standard SQL), or the query is incomplete. Try switching the dialect.
Yes. Separate statements with semicolons and each is formatted with a blank line between them.
It removes comments and extra whitespace to put the query on one line, which is handy for logs, config files or embedding SQL in code. String literals are left untouched.
