Skip to main content
Recently used

Online SQL Editor

Compose and document SQL queries with a focused editor—ideal for reviews and teaching.

Need custom conversion?

Completions appear as you type; press Ctrl+Space to open the list. Tab expands snippets where available. Find: Ctrl+F (Cmd+F on Mac). Format: toolbar button or Ctrl+Shift+B for supported languages.

Choose editor font size in pixels

Compose and document SQL queries with a focused editor—ideal for reviews and teaching.

After editing, you can check structure in sql validator.

Related technologies: PostgreSQL, MySQL, dbt, CSV imports — see also MySQL Editor, PostgreSQL Editor, SQL Server Editor.

Drafting SQL for tickets, reviews, and teaching—without connecting this page to a live database.

Write readable SQL with clear aliases, explicit joins, and a LIMIT while you explore. Prefer listing columns over SELECT * in shared snippets so reviews stay focused.

Keep schema changes and destructive statements out of casual scratchpads—pair drafts with your migration process. Format long queries before review so diffs stay reviewable.

Call out the dialect in a comment (Postgres vs MySQL vs SQL Server) when syntax differs—window functions, LIMIT/TOP, and JSON operators are common tripwires.

When you need a structure check on related tabular data, ConversionTab’s CSV/JSON tools and validators can help after you export results from your DB client.

Stable link for this mode: /code-editor/sql

Open this SQL editor, paste or type in the Ace buffer, use find/replace and theme/font controls, then download when ready. Theme choices may stick in local storage on this device—it is not a cloud project.

Editing stays in your browser for normal use (no account required). Do not paste production secrets; save important work to your own repo or encrypted store.

Copy a starter into the editor, rename symbols to match your project, then download. These are teaching/review snippets—not a full app scaffold.

Starter snippet

WITH recent AS (
  SELECT user_id, MAX(created_at) AS last_seen
  FROM events
  GROUP BY user_id
)
SELECT u.id, u.email, r.last_seen
FROM users u
JOIN recent r ON r.user_id = u.id;

Filtered SELECT

-- SQL
SELECT id, email, created_at
FROM users
WHERE active = TRUE
  AND created_at >= CURRENT_DATE - INTERVAL '7 days'
ORDER BY created_at DESC
LIMIT 50;

JOIN + aggregate

SELECT u.id, COUNT(o.id) AS orders
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
GROUP BY u.id
HAVING COUNT(o.id) > 0;

Window function

SELECT id,
       amount,
       SUM(amount) OVER (PARTITION BY user_id ORDER BY created_at) AS running
FROM payments;

Common SQL patterns for variables, control flow, and comments. Adjust style to your team’s formatter before you commit.

Variables

DECLARE @count INT;  -- dialect-specific

Loops

WHILE @i < 10 BEGIN ... END

Functions / methods

CREATE FUNCTION fn_slug(@s NVARCHAR(100)) RETURNS NVARCHAR(100) AS ...

Comments

-- line  /* block */

Variables (session)

-- SQL
SET @limit = 100;
PREPARE stmt FROM 'SELECT * FROM t LIMIT ?';

Conditional filters

SELECT *
FROM products
WHERE (:category IS NULL OR category = :category)
  AND price BETWEEN :min AND :max;

Reporting query with CTE

-- SQL: staged report
WITH daily AS (
  SELECT DATE(created_at) AS d, COUNT(*) AS n
  FROM events
  GROUP BY 1
)
SELECT d, n, SUM(n) OVER (ORDER BY d) AS running
FROM daily
ORDER BY d DESC
LIMIT 30;

Safe migration sketch

-- SQL: additive change
BEGIN;
  ALTER TABLE users ADD COLUMN IF NOT EXISTS locale TEXT;
  UPDATE users SET locale = 'en' WHERE locale IS NULL;
COMMIT;

Does SQL run on ConversionTab servers?
No. Download the query and run it in your database client. This page does not open a live DB connection.
Is my code uploaded while I type?
Normal editing stays in the browser. You do not need an account to draft or download.
Can I change theme and font size?
Yes—use the toolbar above the editor. Preferences can persist in local storage on this device.
When should I use an IDE instead?
Use your IDE for large projects, debugging, secrets, and production builds. This page is for short drafts and reviews.