Format or minify SQL as you type for MySQL, PostgreSQL, SQLite or SQL Server, with keyword case, indent and comma options that never touch your strings.
Initializing in your browser…
Format, minify or convert XML to JSON as you type, with line-and-column error checks, a tree view and XPath queries that handle namespaces.
Format and validate YAML or convert between YAML and JSON as you type, keeping comments, anchors and exact numbers, with YAML 1.1 and 1.2 support.
Minify or beautify JavaScript, TypeScript, CSS, HTML, JSON, XML and SQL as you type, without touching strings or licences, and see the bytes saved.
A slow-query log shows a one-line report query, and you need to read it to see why it is slow.
Logged query (PostgreSQL)
select u.id, u.name, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.note <> 'select from the menu' and u.created_at >= '2024-01-01' group by u.id, u.name having count(o.id) > 2 order by orders desc
Formatted, uppercase keywords, 2-space indent
SELECT u.id, u.name, count(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.note <> 'select from the menu' AND u.created_at >= '2024-01-01' GROUP BY u.id, u.name HAVING count(o.id) > 2 ORDER BY orders DESC
Each clause now starts on its own line, the join condition sits under its JOIN and every AND condition is indented, so it is easy to check which filters apply. The words select and from inside 'select from the menu' stay lowercase because they are part of a string value, and the line under the result reports 1 statement, 14 keywords and 2 string literals kept exactly. Only whitespace and keyword case changed, so the query returns the same rows.
Paste a SQL query and get it laid out clause by clause as you type, with keywords in the case you prefer and syntax colouring, or minify it to one line. String values, quoted names and comments are never changed, and five SQL dialects are understood.
SQL copied from an application log, an ORM debug message or a colleague's chat message usually arrives as one long line. Reading it, reviewing it or spotting a missing join condition is much easier when each clause starts on its own line and conditions are indented under it. This formatter does that instantly in your browser, for a single query or a whole script.
Formatting that cannot break your query. The formatter reads the SQL as tokens first, the same way a database does, so it knows what is a keyword, what is a string literal, what is a quoted identifier and what is a comment. That sounds obvious, but simpler formatters use search-and-replace and end up upper-casing words inside values ('select from the menu' becoming 'SELECT FROM the menu'), splitting a value at a comma, or breaking a UNION into two words. Here only real keywords change case, and everything inside quotes or comments is copied exactly, so the formatted query returns the same rows as the original.
Dialects. Databases disagree on details that decide where a string ends. MySQL treats a backslash inside a string as an escape and quotes names with backticks; SQL Server uses square brackets; PostgreSQL has dollar-quoted strings such as $$ ... $$ for function bodies; standard SQL and SQLite double a quote to escape it. Choose your dialect and those rules are applied, which matters when a value contains quotes, backslashes or something that looks like a comment.
Your style. Keywords can be UPPERCASE, lowercase or left as written. Indent with 2 or 4 spaces, put commas at the end of each line or at the start of the next (leading commas make it easy to comment out a column), and choose whether clauses are separated by a blank line. Select lists, joins with their ON conditions, WHERE conditions joined by AND or OR, GROUP BY, HAVING, ORDER BY and LIMIT each get a clear place, and CTEs, subqueries, INSERT, UPDATE and CREATE TABLE statements are handled too.
Minify and check. Minify mode does the opposite: it removes comments and collapses whitespace into a single line while keeping strings intact, which is handy for embedding a query in code or a configuration file. A line under the result counts statements, keywords, string literals, quoted names, comments and bind parameters, so you can see at a glance that nothing was lost. Your SQL never leaves your browser, which matters for queries that contain table names, customer data or credentials.
Turn a one-line query from an ORM log or slow-query log into readable SQL to understand what the application actually runs.
Format a migration or report query consistently before committing, so reviewers can see each condition and join clearly.
Tidy a query before pasting it into documentation, a ticket or a chat, with keyword case matching your team's style.
Minify a formatted query into a single line for a string constant or configuration file without breaking its literals.
A lowercase query joining users and orders, with a WHERE, GROUP BY, HAVING and ORDER BY, formats to eleven lines with keywords upper-cased, the join condition indented under LEFT JOIN and each AND condition on its own line.
In WHERE u.note <> 'select from the menu', the words select and from stay lowercase because they are inside a string literal, and the keyword count does not include them.
With the MySQL dialect, 'It\'s fine' is read as one string containing an apostrophe; under standard SQL the same text would end the string early, which is why the dialect matters.
No. Only whitespace and the letter case of keywords change. String literals, quoted identifiers, numbers and comments are kept exactly, so the query returns the same results.
The one your database uses. The choice affects how strings and names are recognised: MySQL uses backticks and backslash escapes, SQL Server uses square brackets, PostgreSQL supports dollar-quoted strings, and standard SQL and SQLite double a quote to escape it. If you are unsure, Standard SQL works for most simple queries.
Uppercase keywords are the most common convention because they separate SQL syntax from table and column names at a glance. Some teams prefer lowercase for less visual noise. Choose As written to leave the case untouched.
Leading commas line up in one column and let you comment out or add a column by touching a single line, which also keeps version-control diffs small. Trailing commas read more like normal prose. Both produce the same query.
Yes. Paste a script with statements separated by semicolons; each statement is formatted and the count under the result tells you how many were found.
No. Formatting runs entirely in your browser, so queries containing table names, data or credentials stay on your device. The share link stores only your formatting settings.
Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.