SQL Formatter
Format and beautify SQL queries across MySQL, Postgres and more dialects.
Turn dense SQL into readable queries
The SQL Formatter takes a cramped, single-line query and reflows it into clean, indented SQL with keywords, joins and clauses laid out on their own lines. It supports many dialects — Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, BigQuery and SQL Server (T-SQL) — so the formatting respects the syntax you actually write. You can also control keyword casing, choosing to preserve it or force keywords to UPPERCASE or lowercase.
How it works
Paste your query, pick a dialect, and the tool formats it in your browser using a JavaScript formatting engine. There is no server call: your SQL, including table names and any values in the query, is processed locally and never uploaded. The formatted result appears side by side with your input and can be copied or downloaded as a .sql file.
Practical uses
- Make a machine-generated or ORM-logged query readable before debugging it.
- Standardize query style across a team or a pull request.
- Prepare examples for documentation, tickets or Stack Overflow answers.
- Spot missing joins or misplaced conditions once the clauses are lined up.
It pairs well with the rest of the data toolkit. Format the payloads a query returns with the JSON Formatter, tidy configuration and feeds with the XML Formatter, or turn exported result sets into structured data with CSV to JSON.
The SQL Formatter is free, requires no sign-up and runs in every modern browser, including on mobile. Because all formatting happens client-side, your queries stay private on your own device.
Frequently asked questions
It handles Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, BigQuery and SQL Server (T-SQL). Pick the dialect that matches your query so keywords and syntax are formatted correctly.
Related tools
XML Formatter
Pretty-print and indent XML, or collapse it back into one line.
HTML Beautifier
Format and indent messy HTML into clean, readable markup.
CSS Beautifier
Beautify and indent CSS with consistent spacing and formatting.
JavaScript Formatter
Format and beautify JavaScript with proper indentation and spacing.