SQL Formatter

Neatly align SQL queries by keywords and clauses.

Category: Dev Tools

When to use?

Use it to tidy a one-line SQL query for readability, or to format a query into a standard form before code review.

How to use

  • Paste the SQL query.
  • Press format to align by keywords and clauses.
  • Copy the tidied query.

Input Explanation

Enter the original SQL query string (SELECT, INSERT, UPDATE, etc.).

Calculation Basis

It tokenizes the SQL via regex or a dedicated parser, then inserts line breaks and indentation around major reserved words like SELECT, FROM, and WHERE for structured alignment.

Usage Examples

  • Review queries - Tidy one-line SELECT, JOIN, WHERE queries for readability.
  • Quick pre-deploy check - Check inputs and output to reduce errors before dev/ops work.
  • Aid docs/reviews - Copy the tidied result into dev docs, issues, or review comments.

Examples

  • "SELECT * FROM users WHERE id=1" → multi-line with reserved-word indentation
  • A one-line query with many JOIN/WHERE → indented by clause for readability

Cautions

  • The entered query is processed only in the browser and not sent to a server.
  • Specific web-standard specs or framework-only syntax may cause compatibility issues.

Guides

Improve SQL readability

It line-breaks and indents major clauses like SELECT, FROM, WHERE, and JOIN so you can grasp long-query structure quickly.

Verify before running

Formatting is only string tidying and does not run or validate the query. Check syntax and results in your DB before running.

FAQ

Is the query sent to a server?

No. It only formats the SQL string in the browser.

How are reserved words shown?

It uppercases SQL reserved words like SELECT, JOIN, WHERE for alignment.

Does it format very long queries?

Yes, it indents long queries with subqueries and joins by clause to reveal structure.

Does it show query results?

No, it only aligns the query. Run it in a database tool.

Related Tools

  • Code Diff Tool - Compare two code or text inputs line by line to show additions and deletions.
  • JavaScript Formatter - Tidy JavaScript code for readability using Prettier rules.
  • JSON Formatter - Beautify or minify JSON strings instantly and check for validity errors.
  • Regex Tester - Enter a regex pattern to see matches in text in real time.
  • UUID Generator - Generate up to 20 cryptographically secure UUID v4 values at once.
  • Password Generator - Generate secure random passwords in the browser by choosing length, character set, and count.