DevTools Logo

DuckDB WASM Playground

DuckDB WASM Playground

Run SQL analytics on local data. Queries and files stay in this tab.

Status: Not connected

Try an example

SQL

1 statement

Results

Run a query to see results

The first run downloads the DuckDB engine.

DuckDB WebAssembly loads only when you connect. Use read_csv_auto('data.csv') or read_json_auto('data.json') for local analytics; your data never leaves the browser.

Examples

Comment-safe batch split

Input
splitDuckDbStatements("SELECT 1; -- note;\nSELECT 'a;b'")
Output
["SELECT 1", "-- note;\nSELECT 'a;b'"]

Semicolons inside comments and string literals never split statements.

Bigint-safe normalization

Input
normalizeDuckDbResult({ schema: { fields: [{ name: "id" }] }, toArray: () => [{ id: BigInt(4) }] })
Output
{ columns: ["id"], rows: [{ id: "4" }] }

Schema fields name the columns while the bigint renders as a string.

About this tool

DuckDB WASM Playground runs analytical SQL in the browser with connectDuckDb and executeDuckDb(sql, connection): the @duckdb/duckdb-wasm bundle lazy-loads behind a Web Worker, statements execute in order, and the last result normalizes to { columns, rows }.

Splitting is comment- and literal-safe through splitDuckDbStatements: single, double, and backtick quoting with doubled-quote escapes plus line and block comments keep semicolons inside 'a;b' or /* x; */ intact, while empty input yields no statements.

Result shaping is deterministic through normalizeDuckDbResult: Arrow-style toArray results and plain record arrays both normalize, bigint values stringify without precision loss, dates become ISO strings, schema fields win for columns, and empty SQL throws Enter at least one SQL statement.

How to use this tool

  1. Connect the engine

    Start the WASM database in a browser with Web Worker support.

  2. Write SQL batches

    Separate statements with semicolons; quoted and commented semicolons stay intact.

  3. Execute in order

    Run the batch and read the normalized last-statement table.

  4. Check types

    Expect bigints as strings and dates as ISO timestamps in rows.

Use cases

Prototyping analytical queries

Test SELECT, aggregation, and JOIN flows in a disposable browser database.

Splitting migration scripts

Divide multi-statement SQL without breaking quoted or commented semicolons.

Handling 64-bit integers

Read counts and ids above Number.MAX_SAFE_INTEGER as exact strings.

Common mistakes

Mistake:Expecting every statement's rows back.

Fix:Only the final result normalizes — run queries one at a time to keep each table.

Mistake:Sending empty SQL and expecting an empty table.

Fix:Delimiter-only input has no statements, so execution throws instead of returning rows.

Mistake:Parsing bigint results as numbers.

Fix:Bigints arrive stringified to preserve precision — compare them as strings.

Frequently asked questions

What does this tool do?

It connects a browser DuckDB WASM engine with Web Worker support and executes SQL batches via executeDuckDb, returning the normalized last-statement table of columns and rows.

How are statements split and results shaped?

Splitting skips semicolons inside single, double, and backtick quotes with doubled-quote escapes plus line and block comments, and normalization stringifies bigints, ISO-formats dates, and prefers schema fields for columns.

Is my SQL uploaded or stored?

No. WASM startup, batch execution, and result normalization run fully client-side.

Why an empty-statement error, or strings where numbers were expected?

Delimiter-only input has no executable statements so it throws, only the final result returns, and bigints arrive as strings to preserve precision past Number.MAX_SAFE_INTEGER.

References & standards