Glyph WidgetsGlyph Widgets
टूलके बारे मेंसंपर्कब्लॉगगोपनीयताशर्तेंविज्ञापन हटाएंKo-fi पर सहायता करें

© 2026 Glyph Widgets LLC. सर्वाधिकार सुरक्षित।

·

100% क्लाइंट-साइड प्रोसेसिंग

ब्लॉग पर वापस जाएं

SQL Formatter: SQL फ़ॉर्मेट और सुंदर बनाएं

SQL formatter: MySQL, PostgreSQL, SQL Server, SQLite और अधिक के लिए queries सुंदर बनाएं। Keyword casing, indentation और minification। मुफ़्त।

Glyph Widgets
27 फ़रवरी 2026
11 मिनट पढ़ने का समय
sql formattersql beautifiersql ऑनलाइन फ़ॉर्मेटsql pretty printmysql formatter

SQL Formatter क्या है?

SQL Formatter एक ब्राउज़र-आधारित टूल है जो बिना फ़ॉर्मेट, compressed या inconsistent स्टाइल वाली SQL queries को सही indentation और consistent keyword casing के साथ साफ़, पठनीय कोड में बदलता है। डेवलपर्स और डेटा एनालिस्ट लगातार खराब फ़ॉर्मेट किए गए SQL का सामना करते हैं — application code में inline लिखी queries, ORM debug logs से output, documentation से कॉपी किया गया SQL, या ऐसी queries जो incremental edits से अपनी structure खो चुकी हैं।

यह टूल उस raw SQL को लेकर sql-formatter लाइब्रेरी का उपयोग करके dialect-aware formatting लागू करता है, जो Standard SQL, MySQL, MariaDB, PostgreSQL, PL/SQL (Oracle), T-SQL (SQL Server) और SQLite के syntax rules को समझती है। आप अपना target dialect चुन सकते हैं, indentation width सेट कर सकते हैं, keyword uppercase toggle कर सकते हैं, और result को minify कर सकते हैं। सभी processing आपके browser में locally चलती है — बिना server, बिना sign-up, और बिना किसी लागत के।

मुख्य विशेषताएं

  • सही indentation के साथ SQL फ़ॉर्मेट करें — Configurable tabWidth और एक ही paste में कई statements के बीच linesBetweenQueries: 2 spacing के साथ sql-formatter लाइब्रेरी का उपयोग।
  • कई SQL dialects का समर्थन — Standard SQL, MySQL, MariaDB, PostgreSQL, PL/SQL (Oracle), T-SQL (SQL Server), और SQLite में से चुनें। Dialect selection इस बात को प्रभावित करती है कि formatter dialect-specific syntax और reserved words को कैसे handle करता है।
  • Customizable indentation settings — Action bar से 2-space या 4-space indentation चुनें।
  • Uppercase keyword toggle — एक toggle button keywordCase: 'upper' और keywordCase: 'preserve' के बीच switch करता है। जब uppercase active है (default), सभी SQL keywords uppercase में standardize हो जाते हैं (SELECT, FROM, WHERE, JOIN, आदि)। जब disabled हो, keyword casing जैसी है वैसी रहती है।
  • SQL Minify करें — tabWidth: 0 के साथ formatting और result को collapse करके extra whitespace हटाता है। Minified output एक single line होती है।
  • Formatted output clipboard में copy करें — Clipboard API with textarea fallback।
  • .sql file के रूप में download करें — Output को text/sql MIME type के साथ formatted.sql के रूप में save करता है।
  • Keyboard shortcuts — Ctrl+Enter (Cmd+Enter) format करता है; Ctrl+Shift+M (Cmd+Shift+M) minify करता है।

SQL Formatter का उपयोग कैसे करें

स्टेप 1: अपना SQL paste करें

/developer/code/sql-formatter पर टूल खोलें। बाईं ओर Input panel में अपनी SQL query या queries paste करें। Semicolons से अलग की गई कई statements supported हैं — formatter output में प्रत्येक statement के बीच दो blank lines रखता है।

स्टेप 2: Dialect और Options चुनें

Panels के नीचे action bar में:

  1. Dialect चुनें dropdown से: Standard SQL, MySQL, MariaDB, PostgreSQL, PL/SQL (Oracle), T-SQL (SQL Server), या SQLite। सबसे accurate formatting के लिए इसे उस database engine से match करें जिस पर आपकी query run होगी।
  2. Indentation चुनें: 2 या 4 spaces।
  3. Uppercase toggle करें: Uppercase button default रूप से active है। जब active हो, सभी SQL keywords uppercase में normalize होते हैं। इसे off करने के लिए click करें।

स्टेप 3: Format click करें

Format पर click करें या Ctrl+Enter / Cmd+Enter दबाएं। Formatted SQL read-only Output panel में दिखाई देता है। टूल history entry में dialect दिखाता है (जैसे "Formatted POSTGRESQL (2.4 KB)")।

Input example — application debug output से inline query:

select u.id,u.email,u.created_at,count(o.id) as order_count,sum(o.total_amount) as total_spent from users u left join orders o on u.id=o.user_id where u.active=true and u.created_at>='2024-01-01' group by u.id,u.email,u.created_at having count(o.id)>0 order by total_spent desc limit 25

PostgreSQL dialect, 2-space indent, uppercase on के साथ output:

SELECT
  u.id,
  u.email,
  u.created_at,
  COUNT(o.id) AS order_count,
  SUM(o.total_amount) AS total_spent
FROM
  users u
  LEFT JOIN orders o ON u.id = o.user_id
WHERE
  u.active = TRUE
  AND u.created_at >= '2024-01-01'
GROUP BY
  u.id,
  u.email,
  u.created_at
HAVING
  COUNT(o.id) > 0
ORDER BY
  total_spent DESC
LIMIT
  25

स्टेप 4: Minify करें (वैकल्पिक)

Minify पर click करें या Ctrl+Shift+M / Cmd+Shift+M दबाएं ताकि single-line SQL string मिले। Minification के दौरान uppercase और dialect settings अभी भी लागू होती हैं। Minified SQL environment variables, configuration strings, या comparison diffs में queries embed करने के लिए उपयोगी है।

उसी query का minified output:

SELECT u.id, u.email, u.created_at, COUNT(o.id) AS order_count, SUM(o.total_amount) AS total_spent FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.active = TRUE AND u.created_at >= '2024-01-01' GROUP BY u.id, u.email, u.created_at HAVING COUNT(o.id) > 0 ORDER BY total_spent DESC LIMIT 25

स्टेप 5: Copy या Download करें

Output को clipboard पर रखने के लिए Copy click करें। formatted.sql save करने के लिए Download click करें। दोनों buttons तब तक disabled रहते हैं जब तक right panel में output न हो।

व्यावहारिक उदाहरण

ORM Debug Query साफ़ करना

Django या Rails का ORM debug output queries को mixed casing के साथ single line पर log करता है। एक typical Django query log entry:

select "products"."id", "products"."name", "products"."price", "products"."stock_count" from "products" where "products"."category_id" = 12 and "products"."active" = true order by "products"."name" asc

PostgreSQL dialect चुनें (Django double quotes के साथ PostgreSQL quoting use करता है), uppercase enable करें, और Format click करें। Output double-quoted identifiers को preserve करते हुए uppercase keywords के साथ proper indentation दिखाती है।

Stored Procedure की समीक्षा

एक T-SQL stored procedure को version control में single unformatted block के रूप में check in किया गया था। Indented, readable version पाने के लिए T-SQL (SQL Server) dialect चुनें और Format click करें। Formatted version pull request diff में review करना आसान है।

Configuration में Query Embed करना

आपकी application एक report query को YAML configuration file में single-line string के रूप में store करती है। SQL Formatter में proper formatting के साथ query build और test करें, फिर embed करने के लिए compact version पाने के लिए Minify click करें। Minified के साथ formatted version को comment में रखने से configuration file maintainable रहती है।

# Formatted version (पठनीयता के लिए):
# SELECT product_id, SUM(quantity) AS units_sold
# FROM order_items
# WHERE order_date >= :start_date
# GROUP BY product_id
# ORDER BY units_sold DESC

report_query: "SELECT product_id, SUM(quantity) AS units_sold FROM order_items WHERE order_date >= :start_date GROUP BY product_id ORDER BY units_sold DESC"

Tips और Best Practices

Dialect को अपने database से match करें। हालाँकि अधिकांश SQL formatting dialect-agnostic है, sql-formatter लाइब्रेरी dialect-specific syntax (जैसे PostgreSQL में :: cast syntax, T-SQL में TOP, और LIMIT/OFFSET placement differences) को सही dialect select होने पर अधिक accurately handle करती है।

Code review readability के लिए uppercase use करें। Uppercase keywords की SQL convention व्यापक रूप से मान्यता प्राप्त है और structural components (SELECT, FROM, WHERE, JOIN) को identifiers और literals से visually distinct बनाती है।

Diff करने से पहले format करें। Query के दो versions compare करते समय, पहले दोनों को same settings के साथ format करें। Unformatted SQL पर diffs noisy output produce करते हैं क्योंकि एक structural change कई lines को affect कर सकता है।

Multiple statements काम करते हैं। आप एक migration file या script को semicolons से अलग किए गए कई CREATE TABLE, INSERT, और ALTER TABLE statements के साथ paste कर सकते हैं। Formatter visual separation के लिए प्रत्येक statement के बीच दो blank lines produce करता है।

Team conventions के लिए presets save करें। Glyph Widgets supporters dialect, indentation, और uppercase settings को named preset के रूप में save कर सकते हैं। Projects के बीच switch करते समय team के conventions को one click में apply करने के लिए प्रति project एक preset बनाएं।

Common Issues और Troubleshooting

Format click करने के बाद error message — sql-formatter लाइब्रेरी unrecognizable syntax पर error throw करती है। Common causes: selected dialect द्वारा unsupported proprietary extensions, procedural code (PL/pgSQL function bodies, T-SQL BEGIN/END blocks), या application-layer template syntax जैसे {{ variable }} या #{variable} के साथ mixed SQL। Format करने से पहले unsupported portions को remove या comment out करें।

Keywords uppercase में नहीं हो रहे — Confirm करें कि Uppercase button active state में है (filled, primary style)। अगर button outline style में है, तो casing preserve पर set है। Uppercase mode enable करने के लिए एक बार click करें।

गलत dialect unexpected line breaks cause करता है — sql-formatter लाइब्रेरी के line-break rules dialect के अनुसार vary करते हैं। अगर कोई query oddly format हो, तो Standard SQL को dialect के रूप में try करें।

Minified output में कुछ जगह multiple spaces हैं — Minification approach सभी whitespace sequences को single spaces में collapse करता है। हालाँकि, quoted string content affected नहीं होता — single-quoted strings के अंदर spaces preserve रहते हैं।

"Please enter SQL to format" error — Input empty है। Format click करने से पहले left panel में SQL query paste करें।

Downloaded file हर बार formatted.sql नाम की होती है — यह fixed filename है। अपने project की naming convention से match करने के लिए download के बाद file rename करें।

Privacy और Security

SQL Formatter sql-formatter लाइब्रेरी का उपयोग करके आपके browser में locally सभी SQL text process करता है। कोई भी query text — table names, column names, data values, connection strings में credentials, या कोई भी अन्य content — server को नहीं भेजा जाता। Page load होने के बाद टूल offline काम करता है। यह इसे proprietary schema names, internal business logic, या sample data वाली queries के साथ उपयोग के लिए safe बनाता है।

अक्सर पूछे जाने वाले प्रश्न

क्या SQL Formatter मुफ़्त है? हां, पूरी तरह मुफ़्त। सभी formatting, minification, और dialect options बिना किसी fee या account के उपलब्ध हैं। Glyph Widgets supporter features जैसे saved presets और session history Ko-fi supporters के लिए उपलब्ध हैं, लेकिन core SQL formatting unrestricted है।

क्या यह offline काम करता है? हां। Page load होने के बाद, सभी formatting JavaScript का उपयोग करके आपके browser में locally चलती है। आप internet से disconnect हो सकते हैं और बिना interruption के queries format करना जारी रख सकते हैं।

क्या मेरा SQL सुरक्षित है? हां। आपका SQL कभी भी किसी server को transmit नहीं होता। यह पूरी तरह browser memory में process होता है और जब आप टूल clear करते हैं या tab बंद करते हैं तो discard हो जाता है।

कौन से SQL dialects supported हैं? टूल Standard SQL, MySQL, MariaDB, PostgreSQL, PL/SQL (Oracle), T-SQL (SQL Server), और SQLite को support करता है। ये सीधे sql-formatter लाइब्रेरी के language parameter से correspond करते हैं।

क्या टूल SQL syntax validate करता है? sql-formatter लाइब्रेरी SQL format करने के लिए पर्याप्त parsing करती है और कुछ syntax पर error throw करेगी जो handle नहीं हो सकता, लेकिन यह strict sense में SQL validator नहीं है। True syntax validation के लिए अपने database engine का EXPLAIN या query planner use करें।

क्या मैं एक साथ कई queries format कर सकता/सकती हूं? हां। Semicolons से अलग किए गए कई statements paste करें। Formatter प्रत्येक formatted statement के बीच दो blank lines रखता है, queries के बीच boundaries clear करता है।

Uppercase toggle exactly क्या करता है? Enable होने पर, formatter sql-formatter options में keywordCase: 'upper' set करता है, जो सभी SQL reserved words को uppercase में convert करता है — SELECT, FROM, WHERE, JOIN, ON, GROUP BY, ORDER BY, LIMIT, function names जैसे COUNT, SUM, MAX, आदि। Disabled होने पर, keywordCase: 'preserve' आपकी input की जो भी casing है वो unchanged रहती है।

क्या formatter CTEs (Common Table Expressions) handle करता है? हां। CTEs (WITH ... AS (...)) CTE definition और उसके बाद की main query के लिए proper indentation के साथ correctly format होते हैं। यह सभी supported dialects पर लागू होता है।

Format करने का keyboard shortcut क्या है? Windows/Linux पर Ctrl+Enter या macOS पर Cmd+Enter। Minify करने के लिए Windows/Linux पर Ctrl+Shift+M या macOS पर Cmd+Shift+M।

क्या मैं CREATE TABLE जैसे DDL statements format कर सकता/सकती हूं? हां। sql-formatter लाइब्रेरी DDL (CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, आदि) के साथ-साथ DML (SELECT, INSERT, UPDATE, DELETE) और DCL (GRANT, REVOKE) को handle करती है। DDL और DML दोनों वाले mixed scripts semicolons से अलग होने पर correctly format होते हैं।

संबंधित टूल्स

JSON Formatter — JSON data को schema validation, schema generation, और interactive tree viewer के साथ format और validate करें।

XML Formatter — XML documents को configurable indentation और minification के साथ format और validate करें।

YAML Formatter — YAML configuration files को format करें और उन्हें JSON में convert करें।

अभी SQL Formatter आज़माएं: SQL Formatter

अंतिम अपडेट: 27 फ़रवरी 2026

पढ़ना जारी रखें

और लेखSQL Formatter आज़माएं