Category: Developer tools
SQL Formatter
Re-indent SQL, set keyword case and preserve comments without uploading the query
Format a SQL query in your browser: choose 2 or 4 spaces, set keyword case, preserve comments and strings, count statements, and copy the readable result.
Paste a SQL query to format it.
The result will appear here.
Everything on this page is processed in your browser. Nothing is uploaded.
What this tool does
This SQL formatter is for one pasted SQL text block. It tokenizes comments, quoted strings, quoted identifiers, numbers, words and operators before making layout decisions, then breaks before major clauses such as SELECT, FROM, WHERE, GROUP BY, HAVING and ORDER BY. You can choose 2- or 4-space indentation and decide whether recognized SQL keywords should be uppercased, lowercased or kept as typed. Compound joins such as LEFT JOIN stay together, AND, OR and ON are indented one level deeper than their clause, and a parenthesis that contains a sub-statement becomes an indented block while a plain value list stays inline. Multiple statements separated by semicolons are spaced apart and counted. The tool does not validate SQL, report syntax errors, execute a query, connect to a database, pick a dialect, minify SQL, highlight syntax, produce an EXPLAIN plan, suggest indexes or process .sql files. It only reflows whitespace and keyword case. The query and formatted result stay in the browser and are not uploaded to LocalTools.
How to use it
- Paste a SQL text block or load the built-in sample and replace it with your query.
- Choose 2- or 4-space indentation and set SQL keywords to uppercase, lowercase or keep-as-typed.
- Review the formatted SQL and statement count, then copy the result with comments and strings preserved.
Privacy
This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.
Frequently asked questions
- Is my SQL sent to a server?
- No. The formatter runs in the browser, so the query you paste and the result you copy are not uploaded to LocalTools.
- Can it uppercase SQL keywords?
- Yes. Choose uppercase, lowercase or keep-as-typed. The setting applies to recognized SQL keywords; words outside the built-in list are treated as identifiers.
- Does it keep comments and quoted strings?
- Yes. It preserves single-quoted strings, doubled quote escapes, quoted identifiers, line comments and block comments while it changes whitespace around them.
- Can this minify SQL into one line?
- No. This page is a formatter and beautifier, not a compact mode or minifier. It expands SQL into readable lines instead of shrinking it.
- Will it validate or run my query?
- No. It does not connect to a database, execute SQL, report dialect syntax errors, produce EXPLAIN plans or optimize the query. It only changes formatting.