SQLフォーマッター
最終更新:
ツールについて
SQL フォーマッターはインデント整形・キーワードの大文字化・節ごとの改行で、長い SELECT も読める形に整えます。アプリ埋め込み用に改行を取り除く minify モードも搭載。1 行に書かれた 50 行分のクエリを読まされた経験がある人に。
使い方
- Paste the SQL query into the input panel.
- Click Format to render an indented, keyword-uppercased version on the right.
- Use Minify to collapse the formatted query into a single line for embedding.
- Copy the result into your IDE, ORM raw query, BI tool, or migration file.
- Iterate until the query reads naturally — formatting helps catch missing JOIN conditions and stray commas.
主な使用例
- Cleaning up a complex JOIN before pasting it into a code review.
- Formatting an ORM-generated query you copied from a log for debugging.
- Preparing a migration script for a Pull Request that follows team style.
- Minifying a query for embedding inside an application config string.
- Comparing two slightly different queries with a diff tool after formatting both.
- Sharing a readable query in documentation or a Slack thread.
よくある質問
Q. Does the formatter validate my SQL?
A. No — it formats syntax structure but does not verify that columns or tables exist or that the query runs. Use a database client or linter for validation.
Q. Will formatting work for non-standard SQL dialects?
A. Mostly. Common keywords across PostgreSQL, MySQL, SQLite, and MSSQL are recognised. Vendor-specific syntax (PIVOT, MERGE) may format with awkward indentation.
Q. Why does my formatter break a CTE in the wrong place?
A. CTEs (WITH clauses) and subqueries are tricky. If the result looks off, hand-tweak after formatting — it is still faster than starting from scratch.
Q. Should I commit formatted SQL to my repo?
A. Yes — consistent SQL formatting in migrations and stored procedures pays off in code review, just like JS/Python formatting.