Input SQL

Formatted SQL

Last updated

Common SQL Formatting Use Cases

All formatting happens entirely in your browser. Supports MySQL, PostgreSQL, SQL Server, Oracle, and SQLite dialects. Your queries are never transmitted to any server.

Examples

Example 1: Basic SELECT Query

Input (minified):

SELECT u.id,u.name,u.email,o.total FROM users u JOIN orders o ON u.id=o.user_id WHERE u.active=1 AND o.status='completed' ORDER BY o.total DESC LIMIT 10

Output (formatted):

SELECT
  u.id,
  u.name,
  u.email,
  o.total
FROM users u
JOIN orders o ON u.id = o.user_id
WHERE
  u.active = 1
  AND o.status = 'completed'
ORDER BY o.total DESC
LIMIT 10

Example 2: Complex Multi-Table JOIN

Input:

select u.name,p.title,c.content,c.created_at from users u inner join posts p on u.id=p.author_id left join comments c on p.id=c.post_id where u.role='author' and p.published=true and c.approved=true order by c.created_at desc

Output:

SELECT
  u.name,
  p.title,
  c.content,
  c.created_at
FROM users u
INNER JOIN posts p ON u.id = p.author_id
LEFT JOIN comments c ON p.id = c.post_id
WHERE
  u.role = 'author'
  AND p.published = true
  AND c.approved = true
ORDER BY c.created_at DESC

Example 3: Subquery Formatting

Input:

SELECT * FROM products WHERE category_id IN (SELECT id FROM categories WHERE parent_id = (SELECT id FROM categories WHERE name = 'Electronics'))

Output:

SELECT *
FROM products
WHERE
  category_id IN (
    SELECT id
    FROM categories
    WHERE
      parent_id = (
        SELECT id
        FROM categories
        WHERE name = 'Electronics'
      )
  )

Frequently Asked Questions

Yes, our Sql Formatter is completely free with no registration required. Use it unlimited times without any restrictions.

Yes, all processing happens locally in your browser. Your data never leaves your device and is not stored on our servers.

No installation needed. The tool works directly in your web browser on any device.

No, formatting only changes the visual presentation. Your actual data remains unchanged.

Yes, use the available options to adjust indentation, spacing, and other formatting preferences.