จัดรูปแบบและปรับปรุง SQL queries ด้วยการขึ้นบรรทัดใหม่สำหรับ clause และการใช้ตัวพิมพ์ keyword สม่ำเสมอ หรือย่อให้เป็นบรรทัดเดียว
วิธีใช้ SQL Formatter
วาง SQL query ของคุณลงในกล่องอินพุต
เลือก จัดรูปแบบ เพื่อปรับปรุงหรือ ย่อ เพื่อบีบอัดเป็นบรรทัดเดียว
เลือกการใช้ตัวพิมพ์ keyword แล้วคัดลอกผลลัพธ์
This is a SQL formatter that takes a cramped, single-line or inconsistently styled query and beautifies it: each major clause on its own line, columns and conditions indented, and keyword casing made consistent. It can also do the reverse and minify a query to one line.
Readable SQL is easier to review, debug and maintain. When SELECT, FROM, WHERE, JOIN and GROUP BY each start a new line and the keywords share one casing, the shape of the query, what it returns and how it filters, becomes obvious at a glance.
Formatting is also useful right before committing a query so diffs stay small and reviewers see meaningful changes rather than reflowed whitespace.
You choose the keyword casing (for example uppercase keywords, which is the common convention) and whether to format or minify. The formatter is dialect-agnostic and handles the common ANSI SQL used by PostgreSQL, MySQL, SQLite and SQL Server.
Minify mode is handy for the opposite need: collapsing a formatted query back to a single line to embed in code or a config value.
The tool formats for readability rather than checking that your query is valid, so it will happily lay out a query with a typo in it. Treat clean output as a readability win, not a correctness check.
Everything runs in your browser, which matters because real queries often contain table names, column names and sometimes literal values that hint at your schema or data. None of that is uploaded.
คำถามที่พบบ่อย
วาง clause หลักเช่น SELECT, FROM, WHERE และ JOIN แต่ละตัวในบรรทัดของตัวเอง เยื้องคอลัมน์และเงื่อนไข และทำให้การใช้ตัวพิมพ์ keyword สม่ำเสมอเพื่อให้อ่านได้
ไม่ การจัดรูปแบบทำงานทั้งหมดในเบราว์เซอร์ของคุณ ดังนั้น queries ของคุณจะไม่ออกจากอุปกรณ์ ทำให้ปลอดภัยสำหรับ queries ที่กล่าวถึงชื่อตารางหรือคอลัมน์
ไม่เฉพาะ dialect และจัดการ ANSI SQL ทั่วไปที่ใช้โดย PostgreSQL, MySQL, SQLite และ SQL Server จัดรูปแบบเพื่อให้อ่านได้ ไม่ใช่ตรวจสอบ syntax
ฝังเครื่องมือนี้
เพิ่มเครื่องมือนี้ลงในเว็บไซต์ของคุณเอง คัดลอกสคริปต์ด้านล่าง โดยจะอัปเดตให้เป็นปัจจุบันโดยอัตโนมัติ
<iframe src="https://monu.tools/embed/th/sql-formatter" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>เครื่องมือที่เกี่ยวข้อง
ปรับปรุง XML ด้วยการเยื้องที่เหมาะสม หรือย่อให้เป็นบรรทัดเดียว ความคิดเห็น CDATA และคำสั่งประมวลผลถูกเก็บไว้
ปรับปรุง CSS ด้วยการเยื้องที่สะอาด หรือย่อเพื่อลดขนาดไฟล์ จัดการ media queries, calc() และ license comments
ปรับปรุง HTML ด้วยการเยื้องที่รู้จัก block หรือย่อ เนื้อหาของ pre, textarea, script และ style ถูกเก็บไว้
ปรับปรุงและทำให้ JavaScript สวยงามด้วยการเยื้องและช่องว่างที่สม่ำเสมอ ทำงานทั้งหมดในเบราว์เซอร์ของคุณ