SQL Formatter
Indent a query so it is readable. Pick the dialect that matches your database. The query is not run, explained or linted — it is only reprinted.
SQL and dialect
Limits
- The input is limited to 2 MB of UTF-8 text (8 MB if you load a file). Larger files can run out of memory in a phone browser tab.
- Not a SQL executor, linter or migration tool. Nothing is sent to a database.
- Dialect coverage is whatever sql-formatter implements. Procedural blocks (PL/pgSQL, T-SQL batches with unusual GO usage) may format poorly.
- Keyword casing follows the library’s style and may not match your house style.
- A query that does not parse in the chosen dialect will return an error instead of a best-effort indent.
Formatted SQL
How to use SQL Formatter
- Paste a queryType, paste or load a .sql file.
- Pick a dialectStandard SQL, MySQL, MariaDB, PostgreSQL, SQLite, Transact-SQL (SQL Server) or others supported by sql-formatter.
- Copy or downloadCopy the result or download a .sql file.
Formatting is not execution
sql-formatter (MIT) parses your query for the selected dialect and reprints it with consistent indent and keyword casing. Dialects differ: a PostgreSQL-only operator may not format well if you leave the dialect on MySQL, and the other way around.
The query never runs. There is no connection to a database, no EXPLAIN, and no guarantee that a reformatted query is accepted by your server.
Frequently asked questions
Is my text or file uploaded?
No. Everything runs in your browser tab with JavaScript. Nothing you type, paste or drop is sent to a server, logged or stored by ALink Tools.
Which dialect should I pick?
The one your database actually uses. If you are unsure, start with the generic SQL option and switch if the formatter reports a parse error.
Will this change the meaning of my query?
It should only change whitespace and casing. If a parse fails, the original text is not replaced. Still, review the result before you run it.
Can I format several statements at once?
Yes, if they parse as a script in the chosen dialect. A trailing semicolon style depends on the library.
Related tools
All toolsJSON Formatter & Validator
Format, minify, sort keys, and catch syntax errors cleanly.
CSV to JSON
Parse CSV into JSON in your browser with Papa Parse, with or without a header row.
JavaScript Formatter
Pretty-print or compact JavaScript in your browser with js-beautify.
XML Formatter
Pretty-print or minify XML in your browser, without sending it to a server.