DevTools Logo

SQLite WASM Studio

SQLite WASM Studio

Run SQLite queries locally in an official SQLite WebAssembly database

Runs in your browser
Database: in-memory, kept while this tab is open.
Try an example

SQL

7 lines · 397 chars

Several statements separated by semicolons are supported, including CREATE TRIGGER. Ctrl/Cmd+Enter runs. Your SQL and data stay in this browser tab.

Result

Nothing run yet

Run SQL to inspect results, schema, and foreign-key relationships.

Uses the official @sqlite.org/sqlite-wasm package loaded lazily on demand. Explore sqlite_master schema entries, query result tables, and deterministic foreign-key relationship data locally in your browser.

    Examples

    Quote-safe batch

    Input
    executeSql(db, "CREATE TABLE notes (body TEXT); INSERT INTO notes VALUES ('a;b'); SELECT * FROM notes")
    Output
    { columns: ["body"], rows: [{ body: "a;b" }] }

    The semicolon inside the string literal never splits the INSERT.

    Foreign-key map

    Input
    extractForeignKeyRelations([{ name: "posts", sql: "CREATE TABLE posts (author_id INTEGER REFERENCES users(id))" }])
    Output
    [{ fromTable: "posts", fromColumns: ["author_id"], toTable: "users", toColumns: ["id"] }]

    Inline REFERENCES resolve to a from/to column mapping without running WASM.

    About this tool

    SQLite WASM Studio runs SQL in the browser with createDb, executeSql(db, sql), readSchema(db), and inspectDatabase(db, sql): the official @sqlite.org/sqlite-wasm module lazy-loads, opens an in-memory database, and executes each quote-aware statement in order.

    Splitting is literal-safe through splitSqlStatements: single, double, backtick, and bracket quoting plus doubled-quote escapes keep semicolons inside 'a;b' intact, while empty input returns empty columns and rows without touching the database.

    Schema intelligence is pure with no WASM dependency: extractForeignKeyRelations parses sqlite_master CREATE TABLE SQL for table-level FOREIGN KEY clauses and inline REFERENCES, and executeSql returns the last SELECT, PRAGMA, or WITH result with columns taken from the first row keys.

    How to use this tool

    1. Open the database

      Create an in-memory database — the WASM module loads lazily in the browser.

    2. Run SQL batches

      Separate statements with semicolons; quoted semicolons stay intact.

    3. Read the result

      Check columns and rows from the final SELECT, PRAGMA, or WITH statement.

    4. Inspect relations

      Read schema entries and extracted foreign-key links between tables.

    Use cases

    Prototyping queries

    Test CREATE, INSERT, and SELECT flows in a disposable in-memory database.

    Mapping relationships

    Extract foreign-key edges from CREATE TABLE text for ER sketches.

    Splitting migration scripts

    Divide multi-statement SQL without breaking quoted semicolons.

    Common mistakes

    Mistake:Expecting every statement's rows back.

    Fix:Only the last SELECT, PRAGMA, or WITH result returns — run queries one at a time to keep each.

    Mistake:Reading columns from an empty SELECT.

    Fix:With zero rows there are no keys to list, so columns return empty by design.

    Mistake:Assuming FK extraction needs a live database.

    Fix:extractForeignKeyRelations parses CREATE TABLE strings directly — pass schema entries instead.

    Frequently asked questions

    What does this tool do?

    It opens an in-memory SQLite database via WASM, executes semicolon batches with executeSql, reads sqlite_master with readSchema, and maps relations with extractForeignKeyRelations.

    How are statements split and results picked?

    Splitting respects single, double, backtick, and bracket quoting with doubled-quote escapes, and only the last SELECT, PRAGMA, or WITH result returns with columns from the first row keys.

    Is my SQL uploaded or stored?

    No. WASM execution, schema reads, and FK parsing run fully client-side in a disposable in-memory database.

    Why empty columns, or no FK edge?

    Zero-row SELECTs have no keys so columns stay empty, and only CREATE TABLE text with FOREIGN KEY or REFERENCES clauses yields relations — views and plain tables map to none.

    References & standards