The SQL Formatter rewrites a SQL statement so it is easy to read: keywords in capital letters, each main clause on its own line, and conditions and column lists indented. Everything runs in your browser, so your queries are never sent to a server.
Good to know
SQL formatting changes layout and keyword case only. It never changes what a query returns or how fast it runs, but a readable layout makes mistakes much easier to spot during review.
Dialects differ in small ways, such as how identifiers are quoted (backticks in MySQL, double quotes in PostgreSQL, square brackets in SQL Server). A formatter should keep those quoting styles and your string literals unchanged.
When to use it
- Cleaning up a query copied from a log or an ORM where it appears on one line.
- Making a long report query reviewable in a pull request.
- Teaching or learning SQL, where structure is clearer on separate lines.
Example: Typical result
Input
select id,name from users where active=1 order by name
Result
SELECT id, name
FROM users
WHERE active = 1
ORDER BY name
Common mistakes
- Expecting formatting to optimise the query. It does not. Use the database's query plan for performance.
- Formatting statements that contain vendor-specific syntax may produce slightly different layouts. Read the result before you commit it.
- Being inconsistent with teammates. Agree on a style and use the same formatter for everyone.
Frequently asked questions
- Is my query sent anywhere or executed?
- No. The tool only rewrites the text of your statement in your browser. It never runs the query and never sends it to a server.
- Does formatting change what my query does?
- No. Only the layout and the capitalisation of SQL keywords change. Table names, column names and aliases keep their original capitalisation.
- Which SQL dialect does it use?
- It lays statements out in a common MySQL-like style, which suits standard SELECT, INSERT, UPDATE and DELETE statements. Very unusual or vendor-specific syntax may be laid out differently from what you expect, so review the result.
- Can I format several statements at once?
- Yes. Statements separated by a semicolon are placed on separate lines.
- How are subqueries and CASE expressions shown?
- Subqueries and CASE expressions are indented one level deeper, and AND / OR conditions and long column lists are indented so the structure is easy to follow.
Related searches: format sql query online free · beautify minified sql online · uppercase sql keywords online · sql formatter with subquery indentation
Tìm kiếm liên quan: công cụ format câu lệnh sql online · làm đẹp câu truy vấn sql · định dạng sql viết hoa từ khóa · format câu lệnh select join where