Tool Hub

SQL 格式化

支持 15+ SQL 方言的格式化工具

Formatted SQL
select
  id,
  name,
  email
from
  users
where
  created_at > '2025-01-01'
  and (
    status = 'active'
    or last_login_at > now() - interval '7 days'
  )
order by
  created_at desc
limit
  100;

使用方法

  1. Paste your SQL query or statement into the input.
  2. Pick the dialect that matches your database (PostgreSQL, MySQL, SQLite, and 12+ others).
  3. Choose an indent width and keyword case (upper or lower).
  4. The formatted, readable SQL appears instantly — copy it back into your editor.

示例

  • A one-line query like select id,name from users where age>18 order by name becomes a multi-line statement with SELECT, FROM, WHERE, and ORDER BY each on their own line and the columns indented.
  • Switching the dialect to PostgreSQL keeps double-quoted identifiers intact, while MySQL mode preserves backticks.

生产环境使用前请验证输出。无担保 — 参见 条款.