SQL Formatter & Beautifier
Format, beautify, and minify SQL queries online.
Format และ beautify SQL query — ทันทีในเบราว์เซอร์ของคุณ
SQL ดิบจาก ORM log query หรือการ export ฐานข้อมูลมักเป็นบรรทัดยาวบรรทัดเดียว — อ่านไม่ออก debug ไม่ได้ หรือ review ใน pull request ยาก SQL formatter ฟรีนี้เพิ่ม indentation ที่เหมาะสม ทำให้ reserved keyword เป็นตัวพิมพ์ใหญ่ (SELECT, FROM, WHERE, JOIN, GROUP BY เป็นต้น) และแบ่ง query ซับซ้อนออกเป็นรูปแบบหลายบรรทัด การ format ทั้งหมดทำงาน client-side ดังนั้น database query ชื่อตาราง รายละเอียด schema และข้อมูลที่ sensitive ใน WHERE clause จึงไม่เคยออกจากอุปกรณ์ของคุณ
SQL ที่ไม่ได้ format ใน migration stored procedure หรือ application code เป็นความเสี่ยงใหญ่ใน code review เงื่อนไขที่หายไปใน WHERE clause การ join แบบ Cartesian ที่ไม่ได้ตั้งใจ หรือ logic error ใน CASE statement อาจมองไม่เห็นใน SQL ที่ย่อแล้ว แต่ชัดเจนเมื่อ indent อย่างถูกต้อง SQL ที่ format แล้วยังลด merge conflict ใน version control — ผู้ review สามารถเห็นได้ชัดเจนว่าบรรทัดไหนเปลี่ยนแทนที่จะ diff string ยาวเส้นเดียว
Formatter รองรับ ANSI SQL มาตรฐานและเข้ากันได้กับ MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, Oracle และ BigQuery ฟังก์ชัน dialect เฉพาะ (ISNULL vs COALESCE, DATE_FORMAT vs TO_CHAR, TOP vs LIMIT) ถูกเก็บไว้ตามเดิม Comment (-- บรรทัดเดียว และ /* block */) ถูกรักษาไว้ใน output Subquery และ CTE (WITH clause) ถูก indent อย่างถูกต้องเพื่อแสดงโครงสร้างเชิงตรรกะ
แม้ SQL ที่ format แล้วจะเหมาะสำหรับการพัฒนา แต่บางครั้ง SQL ที่ย่อแล้วก็จำเป็นสำหรับ query ที่ฝังใน application config file stored procedure ที่ whitespace ส่งผลต่อการจับคู่ string loop ที่ sensitive ต่อ performance ซึ่ง overhead การ parse query สำคัญ หรือเมื่อทำงานกับระบบ database ที่มีข้อจำกัดด้านความยาว query การ minify ลบ comment และ whitespace ออกในขณะที่รักษา SQL semantics ทั้งหมด
สองสไตล์ครองตลาด: keyword ตัวพิมพ์ใหญ่กับ identifier ตัวพิมพ์เล็ก (SELECT id FROM users WHERE active = 1) เป็นวิธีดั้งเดิมและค่าเริ่มต้นใน formatter นี้ บางทีมชอบ lowercase ทั้งหมดเพื่อความสอดคล้องกับ ORM สมัยใหม่อย่าง SQLAlchemy หรือ ActiveRecord เลือกหนึ่งและบังคับใช้ด้วย linter (sqlfluff) เพื่อให้ codebase สอดคล้องกัน ไม่ว่าจะเลือกสไตล์ใด การ format สำคัญกว่า keyword case สำหรับการอ่านออก
คำถามที่พบบ่อย
- What SQL dialects are supported?
- The formatter handles standard SQL syntax including SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, JOIN clauses, subqueries, and CTEs. It works with MySQL, PostgreSQL, SQLite, SQL Server, and Oracle syntax since all share a common SQL core.
- What does the formatter do to keywords?
- SQL keywords (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING, etc.) are uppercased for consistency. This is a widely adopted convention that improves readability by visually separating keywords from identifiers.
- Does this send my SQL to a server?
- No. All formatting happens 100% in your browser using JavaScript. Your SQL queries never leave your device, making it safe to use with production query strings and sensitive data.
- What is SQL minification used for?
- SQL minification removes all unnecessary whitespace and comments, producing a single-line query. This is useful for embedding SQL in configuration files, URL parameters, or logging systems where compactness matters.
- Can the formatter handle complex queries?
- Yes, the formatter handles nested subqueries, multiple JOINs, CTEs (WITH clauses), CASE expressions, and window functions. Complex queries are indented based on clause nesting depth.
เครื่องมือที่เกี่ยวข้อง
- JSON Formatter, Validator & Repair Tool
Format, minify, validate, and repair JSON instantly in your browser. Sort keys alphabetically, auto-format on paste, download as file, escape/unescape strings — free, no sign-up, 100% client-side.
- ตัวสร้าง QR Code
สร้าง QR code สำหรับ URL ข้อความ Wi-Fi และอื่นๆ ดาวน์โหลดเป็น PNG
- ตัวสร้างรหัสผ่าน
สร้างรหัสผ่านสุ่มที่แข็งแกร่งด้วยความยาวและชุดอักขระที่กำหนดเอง
- Base64 เข้ารหัส / ถอดรหัส
เข้ารหัสข้อความเป็น Base64 หรือถอดรหัสกลับเป็นข้อความธรรมดา
- URL เข้ารหัส / ถอดรหัส
เข้ารหัสหรือถอดรหัส URL และ query strings ด้วย percent-encoding