Format and beautify SQL queries instantly. Supports MySQL, PostgreSQL, SQL Server, Oracle, and more. Our free online tool processes everything locally in your browser.
Saved Presets is a Supporter feature.
Tool History is a Supporter feature.
Tool Notes is a Supporter feature.
Copy your SQL query and paste it into the input field. The tool accepts any SQL including SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, and more.
Select your SQL dialect (MySQL, PostgreSQL, etc.), indentation level (2 or 4 spaces), and whether to uppercase keywords.
Click 'Format' to beautify your SQL with proper indentation, or click 'Minify' to compress it into a single line.
Once formatted, use the 'Copy' button to copy the result to your clipboard, or click 'Download' to save it as a .sql file.
Our SQL formatter uses the sql-formatter library to parse and format SQL queries. All processing happens locally in your browser, ensuring complete privacy and enabling offline functionality.
The tool tokenizes your SQL query into its component parts: keywords, identifiers, operators, literals, and comments. It then reconstructs the query with proper indentation based on the query structure.
Different SQL dialects have unique keywords and syntax. By selecting the correct dialect, the formatter can properly recognize database-specific keywords and format them correctly.
The formatter applies consistent rules: keywords on new lines, proper indentation for subqueries and joins, aligned column lists, and standardized spacing around operators.
Very complex queries with non-standard syntax may not format perfectly. Some database-specific features may not be fully supported. The formatter focuses on readability, not execution optimization.
Yes, our SQL formatter is completely free with no registration required. You can format unlimited SQL queries directly in your browser without any costs or subscriptions.