inyourbrowser.com

SQL formatter

SQL formatter is a developer tool that beautifies SQL queries with consistent indentation and keyword casing. It supports Standard SQL, MySQL, PostgreSQL, and T-SQL dialects, handles multi-statement scripts, and outputs ready-to-copy formatted SQL. The tool runs in your browser.

Dialect:

Formatting runs entirely in your browser.

How to format SQL

  1. Paste your SQL query into the input area, minified, inline, or unstructured.
  2. Select the SQL dialect if needed: Standard SQL, MySQL, PostgreSQL, or T-SQL.
  3. Click "Format" to apply consistent indentation and keyword casing.
  4. Copy the formatted SQL or download it for use in your query editor or codebase.

Common uses

  • Reformatting minified or auto-generated SQL to make it human-readable, similarly to how JSON formatter works for JSON data
  • Standardising SQL style across a codebase with consistent indentation and keyword casing
  • Preparing SQL queries for documentation or code review using regex testing to verify patterns

Technical specification

  • Algorithm or formula: Lexer-based formatting via the sql-formatter library. The lexer tokenises the input against a dialect-specific keyword list, then a printer re-emits with consistent indentation, line breaks around major clauses, and configurable keyword casing.
  • Browser API or library: sql-formatter (~45 KB minified). Dialect modules for Standard SQL, MySQL, PostgreSQL, and T-SQL (Microsoft SQL Server).
  • Input limits: No hard cap; tested with multi-thousand-line scripts. Multi-statement input (separated by semicolons) is preserved.
  • Output: Formatted SQL string in the output pane, copyable to clipboard or downloadable as a .sql file.
  • Known limitations: The tool does not execute or fully validate the SQL; syntactic errors produce best-effort formatting. Vendor-specific extensions outside the chosen dialect may not be recognised as keywords.

Frequently asked questions

Is my SQL sent to a server?
No. Formatting uses the sql-formatter library running entirely in your browser. All processing runs in your browser.
What dialects are supported?
The tool supports Standard SQL, MySQL, PostgreSQL, and T-SQL (Microsoft SQL Server). Select the appropriate dialect for keyword-specific formatting.
Does it validate the SQL syntax?
The tool formats but does not execute or fully validate SQL. Syntax errors may produce unexpected output but will not cause harm.
Can I format stored procedures or multi-statement scripts?
Yes. The formatter handles multiple statements separated by semicolons and preserves statement boundaries.

Reviewed and tested May 26, 2026.