SQL Formatter

Format and beautify SQL queries for readability. Runs entirely in your browser.

About this tool

Uses the sql-formatterlibrary rather than a hand-rolled parser, since SQL dialects have enough syntax variation that a naive formatter would get many real queries subtly wrong.

Share on LinkedInShare on X
Link to this tool

Copy this HTML to cite this tool from your own site or article.

About SQL Formatter

SQL Formatter formats unformatted SQL queries with consistent keyword capitalization, line breaks, and indentation across major SQL dialects.

How to use SQL Formatter

  1. Paste raw SQL query code into text area.
  2. Select SQL dialect (Standard SQL, MySQL, PostgreSQL, Transact-SQL).
  3. Set keyword case preference (UPPERCASE or lowercase).
  4. Click Format SQL to clean query layout.

Examples

Input: select id,name from users where status='active' Formatted: SELECT id, name FROM users WHERE status = 'active'

FAQ

Does formatting SQL alter query logic or parameter bindings?

No. Formatting adjusts keyword casing and indentation whitespace while keeping query semantics identical.

Are comment lines preserved?

Yes. Single-line (-- comment) and block (/* comment */) SQL comments remain in place.