SQL Formatter and Prettifier
Format SQL queries with keyword uppercasing, proper indentation, and dialect support.
SQL Formatter and Prettifier tool
Example
Input: select id, name from users where active = 1 order by name
Result: SELECT / id, / name / FROM / users / WHERE / active = 1 / ORDER BY / name (clause bodies indented 2 spaces)
Keywords are uppercased and each clause starts on a new line with its contents indented below it.
- Paste your SQL query - whether a single-line statement or a complex multi-join query - into the input area.
- Select your SQL dialect (Standard SQL, MySQL, PostgreSQL, SQLite, T-SQL, or PL/SQL) for dialect-specific parsing.
- Click "Format SQL" to reformat the query with uppercase keywords and 2-space indentation.
- View the beautifully formatted SQL with uppercase keywords, indented clauses, and one column per line.
- Optionally click Minify to compress the SQL into a single compact line instead.
- Click the copy button to copy the formatted SQL for use in your database client or application.
Making SQL Queries Readable
An SQL formatter rewrites a query so each clause starts on its own line, with keywords in uppercase and contents indented below. select id, name from users where active = 1 becomes SELECT with id and name on their own lines, then FROM users, then WHERE active = 1.
Queries copied from logs, ORMs or old code often arrive as one long line. Formatting shows the structure at a glance: which columns are selected, how tables are joined, where each condition sits, and how subqueries and WITH clauses nest. That makes reviews and debugging much faster. The formatter changes only whitespace and keyword case, so the query means exactly the same thing.
Pick a dialect before you format: Standard SQL, MySQL, PostgreSQL, SQLite, T-SQL (SQL Server) or PL/SQL (Oracle). The dialect tells the parser how that database quotes names and which operators exist, such as backticks in MySQL or square brackets in T-SQL. If a statement does not parse, you see the first line of the error. The style is fixed: uppercase keywords, 2-space indentation and one column per line. Minify goes the other way and packs the query onto one line. It removes comments and extra spaces but never touches string literals, quoted names, MySQL /*! */ comments or /*+ */ optimizer hints. That helps when a query has to fit in code, a log line or a URL. For other formats, the JSON Formatter and the XML Formatter work the same way.
Frequently Asked Questions
Related Tools
JSON Formatter and Validator
Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.
Developer ToolsCSS Minifier
Minify CSS by removing whitespace, comments, and redundant code to reduce file size.
Developer ToolsJavaScript Minifier
Minify JavaScript by removing whitespace, line breaks, and comments for smaller files, without renaming your code.
Developer ToolsRegex Tester
Test regular expressions with real-time match highlighting, group capture display, and a pattern library.
Developer Tools