SQL Formatter
Format SQL queries for MySQL, PostgreSQL, SQLite, SQL Server and more with keyword casing options.
About the SQL Formatter
Long SQL queries are much easier to debug when each clause starts on its own line. The SQL Formatter indents queries for the dialect you use and can upper- or lower-case keywords.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the SQL Formatter
- Paste one or more SQL statements.
- Select your dialect (MySQL, PostgreSQL, SQLite, SQL Server and others) and keyword casing.
- Copy or download the formatted SQL.
Frequently asked questions
Why choose a dialect?
Dialects differ in syntax such as quoting, operators and functions. Choosing the right one makes the formatter parse those correctly.
Does it validate my query?
It needs to tokenise the SQL, so badly broken queries are reported, but it does not check table or column names against a database.
Related tools
JSON Formatter
Format and beautify JSON with configurable indentation and optional key sorting. Errors are reported with exact line and column.
HTML Formatter
Beautify messy or minified HTML into clean, indented markup using Prettier, right in your browser.
CSS Formatter
Format CSS, SCSS and Less stylesheets into readable, consistently indented code.
JavaScript Formatter
Beautify JavaScript and JSX with Prettier. Choose indentation, quotes and semicolons.
TypeScript Formatter
Format TypeScript and TSX code with Prettier, including types, generics and decorators.
PHP Formatter
Beautify PHP code following PSR-style formatting with the Prettier PHP plugin.