Skip to content
    SQL PlaygroundLoading SQLite...
    Define Schema
    SQLite DDL
    Data Browser
    No tables yet. Press Run to build the schema.
    Select a table to view data
    SQL Query
    SQLite query
    Query Result

    Run a query to see results here

    SQL Online Compiler and Editor: Run SQLite Queries in Your Browser

    This SQL online compiler runs SQLite, the embedded database engine, entirely inside your browser. WebFiddle loads sql.js 1.14 (SQLite compiled to WebAssembly), creates an in-memory database, runs your CREATE TABLE and INSERT statements, then executes your query and shows the rows in a result grid. Use it as an online SQL editor for practising SELECT, JOIN, GROUP BY, common table expressions and window functions, as a SQL playground for sketching a schema before you build it, or as a SQLite online shell for checking how SQLite treats types, dates and NULLs. Every statement is executed by SQLite, so queries must use SQLite syntax; PostgreSQL and MySQL are not running here.

    How to use the SQL online compiler

    1. In Define Schema, write the statements that build your database: CREATE TABLE, CREATE INDEX, CREATE VIEW and the INSERT statements that fill the tables. Or start from one of the Samples.
    2. In SQL Query, write the statement you want to test, such as a SELECT with a JOIN, a GROUP BY or a window function.
    3. Press Run. The playground creates a new in-memory SQLite database, runs the schema script, then runs your query and shows the result grid with the execution time.
    4. Open each table in the Data Browser, and use New Row to add a row to the current database without editing the schema script.
    5. Press CSV to download the result grid, or Share to copy a link that stores both scripts in the URL.

    Features

    • A real SQLite engine compiled to WebAssembly, not a SQL emulator
    • Separate panes for the schema script and the query you are working on
    • Data Browser listing every table, with up to 100 rows each
    • New Row form that inserts values as bound parameters
    • CSV export of the result grid, with quoting for commas, quotes and line breaks
    • 15 sample schemas and queries, grouped into Basic and Advanced
    • The SQLite version is read from the engine and shown in the toolbar
    • Share links that carry both the schema and the query

    What works and what doesn’t

    • Only SQLite runs here. Syntax specific to other databases fails or behaves differently: ILIKE, NOW() and :: casts are errors, and SERIAL or AUTO_INCREMENT columns are accepted but never generate ids. Use INTEGER PRIMARY KEY for auto-numbered rows.
    • The database lives in memory and is rebuilt from the Define Schema script on every Run. Rows added with New Row disappear on the next Run, and nothing is kept after you close the tab.
    • Full-text search (FTS5) and loadable extensions are not included in this sql.js build. JSON functions, math functions and window functions are available.
    • The result grid shows the first result set. When the query pane holds several SELECT statements, the later ones still run, and a note tells you how many result sets there were.
    • The Data Browser shows at most the first 100 rows of each table.
    • SQLite runs on the page's main thread, so a very slow query, such as a large cross join, makes the page unresponsive until it finishes.
    • Share links store both scripts in the URL, so very large INSERT scripts produce very long links.

    Example programs

    LEFT JOIN with GROUP BY

    Put the CREATE TABLE and INSERT statements in Define Schema and the SELECT in SQL Query. LEFT JOIN keeps customers who have no orders, and IFNULL turns their missing total into 0. Expected rows: Ada with 2 orders and 155.5, Grace with 1 order and 80.25, and Linus with 0 orders and 0.

    -- Define Schema
    CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT NOT NULL, country TEXT);
    CREATE TABLE orders (
      id INTEGER PRIMARY KEY,
      customer_id INTEGER REFERENCES customers(id),
      total REAL,
      placed_on TEXT
    );
    INSERT INTO customers (name, country) VALUES ('Ada', 'UK'), ('Linus', 'FI'), ('Grace', 'US');
    INSERT INTO orders (customer_id, total, placed_on) VALUES
      (1, 120.00, '2026-01-05'), (1, 35.50, '2026-02-11'), (3, 80.25, '2026-02-20');
    
    -- SQL Query
    SELECT c.name, COUNT(o.id) AS orders, IFNULL(SUM(o.total), 0) AS revenue
    FROM customers c
    LEFT JOIN orders o ON o.customer_id = c.id
    GROUP BY c.id
    ORDER BY revenue DESC;

    Running totals and ranking with window functions

    Uses the orders table from the previous example. SUM() OVER builds a running total in date order, while RANK() ranks each order by size. Expected rows: 120 with a running total of 120 and rank 1, 35.5 with 155.5 and rank 3, then 80.25 with 235.75 and rank 2.

    SELECT placed_on, total,
           SUM(total) OVER (ORDER BY placed_on) AS running_total,
           RANK() OVER (ORDER BY total DESC) AS size_rank
    FROM orders
    ORDER BY placed_on;

    How SQLite type affinity stores values

    SQLite converts values according to each column's type affinity instead of rejecting mismatches. The text '42' is stored as the integer 42 in an INTEGER column, 'abc' stays text, the number 42 becomes the text '42' in a TEXT column, and 7.0 is stored as the integer 7. typeof() shows what was actually stored.

    -- Define Schema
    CREATE TABLE readings (n INTEGER, label TEXT);
    INSERT INTO readings VALUES ('42', 42), ('abc', 3.5), (7.0, NULL);
    
    -- SQL Query
    SELECT n, typeof(n) AS n_type, label, typeof(label) AS label_type
    FROM readings;

    Frequently asked questions

    Which database engine does this SQL online compiler use?

    SQLite, compiled to WebAssembly by the sql.js project (sql.js 1.14 (SQLite compiled to WebAssembly)). The current build reports SQLite 3.49.1, and the toolbar shows the version returned by sqlite_version() when the page loads. Your statements run against a real SQLite database held in your browser's memory, not against a remote server.

    Can I run PostgreSQL or MySQL queries here?

    Only when the syntax is also valid SQLite. Standard SELECT, JOIN, GROUP BY, subqueries, common table expressions and window functions work. Engine-specific syntax does not: ILIKE, NOW() and :: casts are errors, and SERIAL or AUTO_INCREMENT columns never generate ids. Test that kind of SQL on the database it was written for.

    Does SQLite support RIGHT JOIN and FULL OUTER JOIN?

    Yes. SQLite has supported RIGHT JOIN and FULL OUTER JOIN since version 3.39, and this build includes both, alongside INNER JOIN, LEFT JOIN, CROSS JOIN and self-joins. Insert a row with no match on one side, then run each join type to see which rows gain NULL columns.

    Is my data saved between runs?

    No. Each Run creates a fresh in-memory database from the Define Schema script, and closing the tab discards it. Rows added with New Row last only until the next Run. To keep your work, press Share: the link stores both the schema and the query, and opening it restores them.

    Is this SQL playground good for learning SQL?

    Yes, for the core language. Because you control both the schema and the data, you can predict a result, run the query and compare. SQLite differs from server databases mainly in its flexible typing, its date and time functions and its lack of stored procedures, so check those areas before moving to PostgreSQL or MySQL.

    Are my queries sent to a server?

    No. SQLite runs inside your browser tab, so the schema, data and queries stay on your device. Only the sql.js WebAssembly file is downloaded, from the jsDelivr CDN, when the page loads. After that, your SQL leaves your machine only if you share a link that contains it.

    Embed this sandbox

    Paste this iframe into any web page and readers can run code without leaving it. The snippet travels in the URL, so there is nothing to host and no account to create. Open the sandbox, write your example, press Share, then append that link’s query string to the embed URL to preload it.

    <iframe src="https://webfiddle.xyz/embed/sql" width="100%" height="480" loading="lazy"
            style="border:1px solid #ddd;border-radius:8px"
            title="WebFiddle sql sandbox"></iframe>
    Preview the embed

    Related articles

    Related sandboxes

    Official documentation