SQL Query Generator
Generates CREATE, INSERT, SELECT, UPDATE, and DELETE statements for four databases.
Format long SQL queries into readable, indented code with each clause on its own line. Pick your database dialect and keyword case.
.sql file.The query is split into tokens with the rules of the chosen dialect, so identifiers in backticks, brackets, or double quotes and dialect-specific operators are read correctly. Formatting uses the open-source sql-formatter library.
SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT) start at the left margin, and their contents are indented below them.AND/OR condition goes on its own line.CASE expressions are indented one more level.COUNT, and data types. Table names, column names, and string values keep their case.Input:
select u.id,u.email,count(o.id) as orders from users u left join orders o on o.user_id=u.id where u.active=1 group by u.id,u.email order by orders desc limit 10
Formatted with uppercase keywords and 2 spaces:
SELECT u.id, u.email, COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.active = 1 GROUP BY u.id, u.email ORDER BY orders DESC LIMIT 10
BEGIN ... END blocks, loops) are formatted, but the indentation inside them is basic.Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL), Oracle PL/SQL, and Google BigQuery.
No. Only whitespace, line breaks, and the case of keywords change. Identifiers and string values are never changed.
It's a style choice; databases don't care. Uppercase keywords are the most common convention because they stand out from table and column names.
No. Formatting runs in your browser, so queries that contain real data stay on your device.
Often used together with the SQL Formatter.
Generates CREATE, INSERT, SELECT, UPDATE, and DELETE statements for four databases.
Re-indents PHP code safely without touching strings, comments, or inline HTML.
Beautifies minified or messy JavaScript with your chosen indent and brace style.