🛝Toolio
All tools

🗃️ SQL Formatter

Paste your SQL and get clean, readable code instantly — keywords uppercased or lowercased, major clauses on new lines, AND/OR/ON indented. Runs entirely in your browser, no upload required.

Your SQL
Lightweight formatter — not a full SQL parser.

About

This SQL formatter is a lightweight, in-browser beautifier that makes raw or minified SQL readable without a full parser. It protects string literals and inline comments so their content is never altered, then applies your chosen keyword casing (uppercase or lowercase). Major clauses — SELECT, FROM, WHERE, JOIN, LEFT JOIN, RIGHT JOIN, INNER JOIN, GROUP BY, ORDER BY, HAVING, LIMIT — each start on a new line. Logical operators AND, OR, and join condition ON are indented beneath their parent clause, giving a clear visual hierarchy. Because everything runs locally in JavaScript, your queries stay on your device and the tool works even without an internet connection.

How to use

  1. Paste your SQL query into the input box — raw, minified, or already partially formatted.
  2. Choose keyword casing: uppercase (SELECT, FROM) or lowercase (select, from), whichever matches your style guide.
  3. Click Format SQL to apply line breaks before major clauses and indent AND, OR, and ON beneath their parent clause.
  4. Review the formatted output in the result panel — string literals and comments are preserved exactly as you wrote them.
  5. Click Copy to clipboard to paste the clean SQL directly into your editor, console, or documentation.

FAQ

Is this SQL formatter free?
Yes, completely free. No account, no subscription, and no usage limits.
Does my SQL get sent to a server?
No. All formatting runs in your browser with JavaScript. Your SQL never leaves your device, so credentials and business logic inside your queries stay private.
Will formatting change my string values or comments?
No. String literals (single-quoted and double-quoted) and inline comments (-- and /* */) are detected and frozen before any transformation, then restored unchanged in the output.
Which SQL dialects are supported?
The formatter handles standard SQL and works well with MySQL, PostgreSQL, SQLite, and MS SQL Server queries. It is a keyword-based beautifier, not a dialect-aware full parser, so highly vendor-specific syntax is preserved but not specially indented.
Can I use it offline or without an internet connection?
Yes. Once the page is loaded, all formatting runs locally in JavaScript. You can disconnect from the internet and continue formatting queries without any interruption.