تخطى إلى المحتوى الرئيسي

منسق SQL

Poorly formatted SQL is hard to read and debug. Our SQL formatter applies consistent indentation, keyword capitalization, and line breaks to make any SQL query — from simple SELECTs to complex multi-join CTEs — immediately readable. It also supports multiple dialects: MySQL, PostgreSQL, SQL Server, Oracle, and SQLite.

إدخال SQL

منسَّق

شارك هذه الأداة
Developer Tools

حول SQL Formatter & Beautifier

Poorly formatted SQL is hard to read and debug. Our SQL formatter applies consistent indentation, keyword capitalization, and line breaks to make any SQL query — from simple SELECTs to complex multi-join CTEs — immediately readable. It also supports multiple dialects: MySQL, PostgreSQL, SQL Server, Oracle, and SQLite.

كيفية الاستخدام

  1. Paste any SQL query (minified or poorly formatted).
  2. Select your SQL dialect for dialect-specific keyword handling.
  3. Choose formatting options: indentation size, keyword case (UPPER/lower), line break style.
  4. See formatted output — copy or download as .sql file.

الصيغة والمنهجية

No mathematical formula — SQL formatting follows convention: keywords UPPERCASE; identifiers lowercase; each clause (SELECT, FROM, WHERE, JOIN, GROUP BY) on its own line; joined conditions aligned; subqueries indented one level. CTEs formatted with WITH clause on its own line, each CTE separately indented.

حالات الاستخدام الشائعة

  • Making auto-generated ORM queries readable for debugging
  • Code review: ensuring SQL in stored procedures follows team standards
  • Documentation: formatting queries before including in technical docs
  • Database administration: reading execution plans with formatted queries
  • Legacy code: reformatting decades-old stored procedures for maintainability

الأسئلة الشائعة

Convention strongly favors UPPERCASE keywords (SELECT, FROM, WHERE, JOIN) with lowercase identifiers (table_name, column_name). This visual contrast makes queries scannable — you can identify the structure at a glance. Most style guides (SQL Style Guide, GitLab SQL Style Guide) require uppercase keywords. Some teams prefer all-lowercase for consistency with the rest of their codebase — choose a convention and enforce it consistently.
CTE (Common Table Expression) is a named temporary result set defined with the WITH clause: WITH monthly_sales AS (SELECT ...) SELECT * FROM monthly_sales. Use CTEs when: (1) a subquery is referenced more than once, (2) the logic is complex and benefits from breaking into named steps, (3) you need recursive queries. CTEs don't always improve performance vs subqueries — the optimizer may inline them anyway — but they dramatically improve readability.

أدوات ذات صلة

كل الأدوات →

دمج هذه الأداة في موقعك

مجاني للاستخدام الشخصي والتجاري. فقط انسخ الكود أدناه.