w

Basic Usage

This guide will walk you through the basic usage of the SQL Prettify and Format tool.

Input Your SQL Query

  1. Navigate to the Tool: Go to the SQL Prettify tool page
  2. Enter SQL Code: In the "SQL Input" textarea, paste or type your SQL query
  3. Automatic Formatting: The tool will automatically format your SQL as you type

Example Input

select u.id, u.name, u.email, p.title, p.content from users u inner join posts p on u.id = p.user_id where u.active = 1 and p.published = 1 group by u.id, u.name, u.email, p.title, p.content order by u.name asc, p.created_at desc limit 10 offset 0;

Configure Formatting Options

Indent Size

Choose the number of spaces for indentation:

  • 2 spaces: Compact formatting
  • 4 spaces: Standard formatting (recommended)
  • 8 spaces: Wide formatting

Keyword Case

Control how SQL keywords are displayed:

  • UPPERCASE: Convert all keywords to uppercase (SELECT, FROM, WHERE)
  • lowercase: Convert all keywords to lowercase (select, from, where)
  • Preserve Case: Keep the original case as typed

Additional Options

  • Uppercase Keywords: Convert SQL keywords to uppercase
  • Uppercase Functions: Convert function names to uppercase
  • Uppercase Data Types: Convert data type names to uppercase
  • Align Commas: Align commas in SELECT lists
  • Break Before Boolean Operator: Add line breaks before AND/OR operators

View Formatted Output

The formatted SQL will appear in the "Formatted SQL" textarea. You can:

  1. Copy to Clipboard: Click the "Copy" button to copy the formatted SQL
  2. View Statistics: Check the statistics panel for formatting details
  3. Save to History: The tool automatically saves your formatting history

Example Output

SELECT
  u.id,
  u.name,
  u.email,
  p.title,
  p.content
FROM users u
INNER JOIN posts p ON u.id = p.user_id
WHERE u.active = 1
  AND p.published = 1
GROUP BY
  u.id,
  u.name,
  u.email,
  p.title,
  p.content
ORDER BY
  u.name ASC,
  p.created_at DESC
LIMIT 10 OFFSET 0;

Quick Actions

  • Load Example: Click "Load Example" to see a sample SQL query
  • Clear: Click "Clear" to remove all content
  • Copy: Click "Copy" to copy the formatted SQL to clipboard

The tool provides real-time formatting, so you'll see results immediately as you make changes to your SQL code or formatting options.

Was this page helpful?