Output will appear here...What is SQL Formatter?

SQL Formatter turns dense, single-line or inconsistently written SQL into readable, review-friendly queries. It puts each major clause - SELECT, FROM, WHERE, JOINs, GROUP BY, ORDER BY, HAVING, LIMIT, UNION - on its own line, breaks SELECT columns onto separate lines, indents AND/OR conditions under their clause, and normalizes keyword casing to upper or lower. The result is the kind of layout you would want in a code review: a 400-character query from an ORM log becomes a structure you can scan for the missing join condition.
As a SQL query formatter it takes a line like select top 10 [Order ID], total from dbo.[Order Details] where total > 100 and status = 'open' and returns SELECT TOP 10 on the first line, [Order ID] and total on their own indented lines, then FROM, then WHERE with the AND condition indented under it. SQL Server users can treat it as a SQL formatter for SSMS: format the T-SQL in this online SQL formatter, then paste it back into SQL Server Management Studio. It is a web page, not an SSMS extension, so there is nothing to install.
Under the hood it is a real tokenizer, not a pile of find-and-replace rules. String literals (including doubled-quote and backslash escapes), double-quoted and backtick-quoted identifiers, bracketed SQL Server identifiers, numbers, operators and both comment styles (-- line and /* block */) are lexed as atomic tokens before any layout decision is made. That means a column value like 'SELECT * FROM users' inside a string is never mistaken for a clause, and formatting can restructure whitespace without ever corrupting literal content.
The Minify mode does the opposite: it collapses a formatted query to a single line - dropping comments, preserving every literal byte-for-byte - which is handy for log grepping, packing queries into JSON payloads or .env files, and comparing query shapes. Everything runs client-side in your browser, so production queries containing table names, customer data in literals or schema details are never uploaded, logged or stored anywhere.
Formatting is tokenizer-based rather than regex-based, so string literals and comments containing SQL keywords are not reformatted as if they were code. Dialects still differ in ways no formatter can settle, particularly around quoting identifiers, so the output is normalised rather than guaranteed portable.
How to use SQL Formatter?
Paste your SQL
Drop in any query - a one-liner from an ORM debug log, a hand-written report query, or a multi-statement script separated by semicolons.
Pick keyword case and indentation
Choose UPPERCASE or lowercase for keywords and 2, 4 or 8 spaces of indentation to match your team conventions.
Click Format or Minify
Format produces clause-per-line output with SELECT columns on their own lines and AND/OR conditions indented. Minify collapses everything to a single line with comments removed and literals untouched.
Copy or download
Copy the result to your clipboard for a code review or migration file, or download it as a .sql file.
Key Features
Tokenizer-based, literal-safe
String literals, quoted identifiers and comments are lexed first - formatting can never alter data inside quotes
Clause-aware line breaks
SELECT, FROM, WHERE, JOIN variants, GROUP BY, ORDER BY, HAVING, LIMIT and UNION each start a new line, with subqueries indented by nesting depth
Keyword case normalization
A comprehensive keyword list (DML, DDL, functions, types) is converted to UPPER or lower case; identifiers are left exactly as written
One SELECT column per line
Comma-separated select lists break onto individual indented lines, making wide queries diffable in pull requests
Frequently Asked Questions
Related Tools
CSS Minifier & Beautifier
Minify CSS to cut file size or beautify minified stylesheets for debugging
HTML Minifier & Beautifier
Minify HTML markup for faster page loads or beautify it for readable, indented source
JSON to SQL Converter
Convert a JSON array of objects into SQL CREATE TABLE and INSERT statements for MySQL, PostgreSQL, or SQLite. Infers types, runs client-side.
Tip Calculator
Calculate the tip and split the bill between any number of people, with sales tax, tip-on-pre-tax, and round-up options.
Comments
0 comments
No comments yet. Be the first to share your thoughts!