SQL Formatter

Help

Overview

The SQL formatter is an online tool that formats and beautifies hard-to-read SQL queries. It aligns keywords such as JOIN, WHERE, and GROUP BY with proper indentation, streamlining code reviews and documentation.

How to Use

  1. Paste your SQL query into the text area.
  2. Select the number of spaces in the Indentation field.
  3. Select the formatting method in Mode: Standard Format / Right-aligned/Tabular / Minify.
  4. Select Uppercase / Lowercase / Preserve in Keywords and Identifiers.
  5. Click the Format button to see the formatted result.

Specifications & Glossary

  • Mode: Formatting method selection
    • Standard Format: Adds line breaks and indentation for readability.
    • Right-aligned/Tabular: Aligns keywords right-justified in tabular form, stacking SQL keywords vertically.
    • Minify: Removes line breaks and extra spaces, compressing to a single line.
  • Keywords: SQL keyword upper/lower conversion
    • Uppercase: Converts all SQL keywords such as SELECT and FROM to uppercase.
    • Lowercase: Converts all SQL keywords to lowercase.
    • Preserve: Preserves the original casing of the input.
  • Identifiers: Converts the case of table names and column names. You can select from Uppercase / Lowercase / Preserve.
  • Indentation: Sets the number of spaces used for indentation in the output SQL (e.g., 2 spaces, 4 spaces).

Use Cases

  • Organizing SQL before code reviews to improve readability.
  • Debugging and analyzing queries auto-generated by ORMs.
  • Creating formatted SQL snippets for documentation.

SQL Formatter Tool

SQL