>_compilebytes

A fast place to write code and run it in isolated hosted runtimes. Free, forever.

Playgrounds

Python compilerC compilerJavaScript compilerC++ compilerTypeScript compilerGo compilerJava compilerRust compiler
All playgrounds →

Tools

JSON formatterRegex testerBase64 encoderJWT decoder
JSON formatterBase64 encoder & decoderRegex testerJWT decoder
All tools →

Company

TermsPrivacy[email protected]
© 2026 compilebytes115 runtimes · no signup115 runtimes · isolated sandboxes · no signup

About the SQL Formatter playground

The SQL Formatter takes minified, inconsistently indented, or single-line SQL and rewrites it into clean, readable statements. It capitalizes keywords, aligns clauses like SELECT, FROM, WHERE, JOIN, and GROUP BY onto their own lines, and indents nested subqueries. Everything runs locally in your browser, so even production queries containing schema names stay on your machine and are never sent to a server.

SQL (Structured Query Language) is the standard language for querying and manipulating relational databases such as PostgreSQL, MySQL, SQLite, and SQL Server. Because SQL is often written inline in application code or generated by ORMs, it frequently arrives as one long line. Consistent formatting makes complex joins and conditions far easier to review, debug, and maintain, and helps teams agree on a shared style during code review.

HostedSQL Formatter runtime
mainentry file
single fileworkspace
stdinprogram input

How it works

1

Write

The main file is the entry point for each run.

2

Give it input

Use the Input panel to pipe standard input to your program when it needs data.

3

Run

Run sends your code to a fresh hosted runtime and streams the result into the output panel.

4

Keep or share

Your draft stays in this browser, and Share creates a separate snapshot link.

External resources

  • postgresql.org— Format reference

Messy input

select id,name,email from users u join orders o on o.user_id=u.id where u.active=1 and o.total>100 order by o.total desc;

Formatted output

SELECT
  id,
  name,
  email
FROM
  users u
  JOIN orders o ON o.user_id = u.id
WHERE
  u.active = 1
  AND o.total > 100
ORDER BY
  o.total DESC;

Subquery formatted

SELECT
  name
FROM
  products
WHERE
  category_id IN (
    SELECT
      id
    FROM
      categories
    WHERE
      active = 1
  );

Aggregation messy input

select dept,count(*) c,avg(salary) avg_sal from employees where hire_date>'2020-01-01' group by dept having count(*)>3 order by c desc;

Aggregation formatted output

SELECT
  dept,
  COUNT(*) c,
  AVG(salary) avg_sal
FROM
  employees
WHERE
  hire_date > '2020-01-01'
GROUP BY
  dept
HAVING
  COUNT(*) > 3
ORDER BY
  c DESC;

INSERT and UPDATE formatted

INSERT INTO
  users (name, email, active)
VALUES
  ('Ada', '[email protected]', 1);

UPDATE
  users
SET
  active = 0,
  updated_at = NOW()
WHERE
  id = 42;

CTE with window function formatted

WITH ranked AS (
  SELECT
    id,
    dept,
    salary,
    ROW_NUMBER() OVER (
      PARTITION BY dept
      ORDER BY salary DESC
    ) AS rn
  FROM
    employees
)
SELECT
  id,
  dept,
  salary
FROM
  ranked
WHERE
  rn = 1;

Multi-join messy input

select o.id,c.name,p.title from orders o join customers c on c.id=o.customer_id left join products p on p.id=o.product_id where o.status='paid';

Multi-join formatted output

SELECT
  o.id,
  c.name,
  p.title
FROM
  orders o
  JOIN customers c ON c.id = o.customer_id
  LEFT JOIN products p ON p.id = o.product_id
WHERE
  o.status = 'paid';

DELETE with predicates formatted

DELETE FROM
  sessions
WHERE
  expires_at < NOW()
  AND user_id NOT IN (
    SELECT
      id
    FROM
      users
  );

How it works

The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.

What it does

Paste a minified or single-line SQL statement and get a clean, readable query back.

Major clauses like SELECT, FROM, WHERE, JOIN and GROUP BY move onto their own lines.

Nested subqueries are indented so the query structure is obvious at a glance.

Formatting behavior

Reserved keywords are normalized to uppercase for a consistent style.

Column lists and ON conditions are aligned under their clauses.

Works with dialects like PostgreSQL, MySQL, SQLite and SQL Server.

Privacy

Formatting runs entirely in your browser, so queries are never sent to a server.

Even production SQL with real schema and table names stays on your machine.

Tips

Copy the formatted query in one click to paste back into your editor.

Great for tidying ORM-generated SQL before a code review.

Every shortcut, searchable:

Editing

Undo
Ctrl+Z
Redo
Ctrl+⇧+Z
Select next occurrence
Ctrl+D
Delete line
Ctrl+⇧+K
Move line up / down
Alt+↑ / ↓
Copy line up / down
Alt+⇧+↑ / ↓
Toggle comment
Ctrl+/
Indent line
Ctrl+]
Outdent line
Ctrl+[

Navigation

Find
Ctrl+F
Find & replace
Ctrl+H
Go to line
Ctrl+G
Go to symbol
Ctrl+⇧+O

Selection

Select all
Ctrl+A
Select line
Ctrl+L
Select all occurrences
Ctrl+⇧+L
Shortcuts follow your OS — ⌘ becomes Ctrl on Windows and Linux.
It reformats raw or minified SQL into clean, indented statements with keywords aligned onto their own lines, making queries easier to read, review, and debug.
No. The formatter runs entirely in your browser using client-side JavaScript. Your SQL, including any schema or table names, never leaves your device.
Yes, the SQL Formatter is completely free to use with no sign-up, account, or usage limits.
Yes. You can choose the indent size (for example 2 or 4 spaces, or tabs) and keyword case so the output matches your team's style guide.
Yes. It handles common dialects such as PostgreSQL, MySQL, SQLite, and SQL Server. Dialect-specific functions are preserved even when not explicitly recognized.
Input
Output

Output

Start typing to auto-process