Try VisuaLeaf's SQL editor, table data grid, table management and schema designer on DuckDB, right here in your browser. No install, no sign-up, and nothing you type leaves your browser.
Working with MongoDB? Try the MongoDB playground
Embed
The playground is built from web components. A blog post, a SQL course or your product docs can show a live DuckDB editor, table or schema diagram with one script tag. The snippet follows the tool and size you picked above.
One script tag from https://visualeaf.com/playground-duckdb/widget/20261121-2249/main.js. We host everything and keep it up to date. Nothing to install or build.
files lists Parquet, CSV or JSON files by URL so FROM 'sales.parquet' just works. init runs a SQL script first: CREATE TABLE, INSERT, views. The files must allow cross-origin requests (CORS).
Put a <visualeaf-sql>, <visualeaf-table>, <visualeaf-table-manager> or <visualeaf-schema> where it should appear, and size it with CSS like any block. Each reader gets their own in-memory DuckDB.
No import step: DuckDB reads Parquet and CSV where they are, nested columns included. name=url gives a file another name.
<visualeaf-sql
files="https://example.com/sales.parquet
rates.csv=https://example.com/fx.csv"
script="FROM 'sales.parquet'
SELECT region, sum(amount)
GROUP BY ALL ORDER BY ALL"></visualeaf-sql>
init runs SQL once before the reader sees the widget. If a statement fails, the widget shows it with DuckDB's message.
<visualeaf-table table="products"
init="
CREATE TABLE products (
id INTEGER PRIMARY KEY,
name VARCHAR, price DECIMAL(10, 2));
INSERT INTO products VALUES
(1, 'Pen', 2.50), (2, 'Notebook', 7);
"></visualeaf-table>
Widgets with the same shared-db share a database, like on this page. Create a table in the editor, browse it further down.
<visualeaf-sql shared-db="store"
init-url="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/store-init.sql"></visualeaf-sql>
<!-- …the text of your post… -->
<visualeaf-schema shared-db="store"></visualeaf-schema>
Reference
Attributes are read when the element starts, so set them before adding it to the page.
| Attribute | What it does |
|---|---|
database | The database the widget works in: an in-memory DuckDB catalog of that name (default memory, DuckDB's own). |
schema | The schema the screens open on (default main). |
files | Files DuckDB reads by name, as whitespace-separated URLs: files="sales.parquet rates.csv" makes FROM 'sales.parquet' work. name=url registers a file under another name. Fetched once at start. |
data | Rows to load first, as JSON: {"table": [{…}, …]}, a table per key. DuckDB infers the column types. |
data-url | The same, fetched from a URL. |
init | A SQL script run once at start, after files and data. A failure stops the widget with the statement and DuckDB's message. |
init-url | The same, fetched from a .sql file. |
shared-db | Widgets on the page with the same value share one database. The first to start opens it with its attributes, and what one changes the others see. |
name | The connection's name in the breadcrumb. |
theme | dark or light. Without it: the reader's choice from the ☀ / ☾ toggle, else dark. |
resizable | false hides the handle readers drag to make the widget taller. |
min-height | The smallest height that handle allows, in px (default 360). |
view | The screen to start on (editor, table, manage, schema), when one element should start on another screen. |
| Attribute | What it does |
|---|---|
script | The editor's initial text. Readers run all of it (each statement gets its own result tab) or just the statement under the cursor. |
script-url | The same, fetched from a .sql file. |
<visualeaf-table> shows a table's rows; <visualeaf-table-manager> its columns, indexes, keys and constraints.
| Attribute | What it does |
|---|---|
table | The table shown (default: the schema's first, alphabetically). |
| Attribute | What it does |
|---|---|
table | Puts that table on the canvas at start. Without it the canvas starts empty: Generate draws every table. |
Want to experiment before putting the widgets on your site? They run on JSFiddle as they are, with no license key: start from our example below, or paste the snippet from the first tab into a fiddle's HTML panel.
The four tools in tabs on one shared DuckDB, a dark mode toggle and a frame you can drag wider. Copy each panel into a new fiddle (HTML, CSS, JavaScript).
<!-- The DuckDB widgets need no license key -->
<script type="module" src="https://visualeaf.com/playground-duckdb/widget/20261121-2249/main.js"></script>
<div class="page">
<header class="top">
<div class="brand">
<span class="logo"><img src="https://visualeaf.com/app/media/logo-3RT6CI2M.svg" alt="VisuaLeaf"></span>
<div>
<h1>VisuaLeaf DuckDB Playground</h1>
<p>DuckDB running entirely in your browser.</p>
</div>
</div>
<button id="themeToggle" class="theme-toggle" aria-label="Toggle dark mode">
<span class="icon-moon">🌙</span><span class="icon-sun">☀️</span>
</button>
</header>
<div class="resize-wrap" id="resizeWrap">
<main class="card">
<div class="card-bar">
<div class="tabs" role="tablist">
<button class="tab active" data-panel="p-sql" role="tab" aria-selected="true">
<svg viewBox="0 0 24 24"><path d="M4 7l5 5-5 5M12 18h8"/></svg>
SQL Editor
</button>
<button class="tab" data-panel="p-table" role="tab" aria-selected="false">
<svg viewBox="0 0 24 24"><path d="M3 5h18v14H3zM3 10h18M3 15h18M9 5v14"/></svg>
Table Data
</button>
<button class="tab" data-panel="p-manage" role="tab" aria-selected="false">
<svg viewBox="0 0 24 24"><path d="M4 6h16M4 12h10M4 18h7M17 14l3 3-3 3"/></svg>
Table Structure
</button>
<button class="tab" data-panel="p-schema" role="tab" aria-selected="false">
<svg viewBox="0 0 24 24"><path d="M3 3h7v6H3zM14 15h7v6h-7zM14 3h7v6h-7zM6.5 9v6h7.5M17.5 9v6"/></svg>
Schema Designer
</button>
</div>
</div>
<section id="p-sql" class="panel">
<visualeaf-sql
database="store"
shared-db="store"
name="Store (DuckDB in your browser)"
files="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/web_events.parquet https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/fx_rates.csv"
init-url="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/store-init.sql"
script-url="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/duckdb-vs-sqlite.sql"
style="width: 100%; height: 760px">
</visualeaf-sql>
</section>
<section id="p-table" class="panel" hidden>
<visualeaf-table
database="store"
shared-db="store"
name="Store (DuckDB in your browser)"
files="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/web_events.parquet https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/fx_rates.csv"
init-url="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/store-init.sql"
table="orders"
style="width: 100%; height: 760px">
</visualeaf-table>
</section>
<section id="p-manage" class="panel" hidden>
<visualeaf-table-manager
database="store"
shared-db="store"
name="Store (DuckDB in your browser)"
files="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/web_events.parquet https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/fx_rates.csv"
init-url="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/store-init.sql"
table="products"
style="width: 100%; height: 760px">
</visualeaf-table-manager>
</section>
<section id="p-schema" class="panel" hidden>
<visualeaf-schema
database="store"
shared-db="store"
name="Store (DuckDB in your browser)"
files="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/web_events.parquet https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/fx_rates.csv"
init-url="https://visualeaf.com/playground-duckdb/widget/20261121-2249/samples/store-init.sql"
style="width: 100%; height: 760px">
</visualeaf-schema>
</section>
</main>
<div class="width-handle" id="widthHandle" title="Drag to resize · double-click to reset"></div>
<div class="width-label" id="widthLabel"></div>
</div>
</div>
/* ===== Theme ===== */
:root {
--bg: #f5f7fa;
--glow-1: rgba(34, 197, 94, .18);
--glow-2: rgba(59, 130, 246, .14);
--grid: rgba(15, 23, 42, .05);
--text: #0f172a;
--muted: #475569;
--card: #ffffff;
--border: rgba(15, 23, 42, .10);
--shadow: 0 20px 50px -20px rgba(15, 23, 42, .25);
--accent: #16a34a;
--tabs-bg: #e9eeeb;
--tab-active: #166534;
}
[data-theme="dark"] {
--bg: #0b0f14;
--glow-1: rgba(34, 197, 94, .14);
--glow-2: rgba(59, 130, 246, .12);
--grid: rgba(255, 255, 255, .04);
--text: #e5e7eb;
--muted: #94a3b8;
--card: #11161d;
--border: rgba(255, 255, 255, .08);
--shadow: 0 20px 60px -20px rgba(0, 0, 0, .7);
--accent: #22c55e;
--tabs-bg: rgba(255, 255, 255, .06);
--tab-active: #4ade80;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
color: var(--text);
background:
radial-gradient(900px 500px at 10% -10%, var(--glow-1), transparent 60%),
radial-gradient(800px 500px at 100% 0%, var(--glow-2), transparent 60%),
linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 32px 32px,
linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 32px 32px,
var(--bg);
background-attachment: fixed;
transition: background-color .3s, color .3s;
}
.page { max-width: none; margin: 0 auto; padding: 32px 24px 24px; }
/* ===== Header ===== */
.top {
display: flex; align-items: center; justify-content: space-between;
gap: 16px; margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
display: grid; place-items: center; width: 44px; height: 44px;
border-radius: 12px; font-size: 22px;
background: var(--card); border: 1px solid var(--border);
}
h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.theme-toggle {
width: 42px; height: 42px; border-radius: 50%; cursor: pointer; font-size: 18px;
background: var(--card); border: 1px solid var(--border); color: var(--text);
transition: transform .2s;
}
.theme-toggle:hover { transform: rotate(15deg) scale(1.05); }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
/* ===== Card ===== */
.card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 16px;
box-shadow: var(--shadow);
overflow: hidden;
}
/* ===== Tabs (new) ===== */
.card-bar {
padding: 12px;
border-bottom: 1px solid var(--border);
}
.tabs {
display: inline-flex;
gap: 4px;
padding: 4px;
border-radius: 12px;
background: var(--tabs-bg);
}
.tab {
display: flex; align-items: center; gap: 8px;
padding: 8px 14px;
border: 0; border-radius: 9px;
background: transparent;
color: var(--muted);
font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
cursor: pointer;
transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab svg {
width: 16px; height: 16px;
fill: none; stroke: currentColor;
stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tab.active {
background: var(--card);
color: var(--tab-active);
box-shadow: 0 1px 3px rgba(0, 0, 0, .10);
}
.panel[hidden] { display: none; }
.panel > * { display: block; }
.logo img {
width: 28px;
height: 28px;
object-fit: contain;
}
.resize-wrap {
position: relative;
width: 1280px; /* starting width */
max-width: 100%; /* never wider than the window */
min-width: 360px;
margin: 0 auto;
}
.width-handle {
position: absolute;
top: 50%;
right: -16px;
transform: translateY(-50%);
width: 8px;
height: 72px;
border-radius: 4px;
background: var(--border);
cursor: ew-resize;
transition: background .15s, height .15s;
touch-action: none;
}
.width-handle:hover,
.resizing .width-handle {
background: var(--accent);
height: 96px;
}
.width-label {
position: absolute;
top: -30px;
right: 0;
padding: 3px 8px;
border-radius: 6px;
font-size: 12px;
font-variant-numeric: tabular-nums;
background: var(--card);
border: 1px solid var(--border);
color: var(--muted);
opacity: 0;
transition: opacity .15s;
pointer-events: none;
}
.resizing .width-label { opacity: 1; }
/* while dragging: stop the widgets from stealing the mouse, no text selection */
.resizing visualeaf-sql,
.resizing visualeaf-table,
.resizing visualeaf-table-manager,
.resizing visualeaf-schema { pointer-events: none; }
body.no-select { user-select: none; cursor: ew-resize; }
/* ===== Footer ===== */
footer { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
const root = document.documentElement;
const widgets = document.querySelectorAll("visualeaf-sql, visualeaf-table, visualeaf-table-manager, visualeaf-schema");
const system = matchMedia("(prefers-color-scheme: dark)");
function getSaved() { try { return localStorage.getItem("theme"); } catch { return null; } }
function save(t) { try { localStorage.setItem("theme", t); } catch {} }
function apply(theme) {
root.dataset.theme = theme;
widgets.forEach(w => w.setAttribute("theme", theme)); // widgets follow the page
}
apply(getSaved() || (system.matches ? "dark" : "light"));
system.addEventListener("change", e => { if (!getSaved()) apply(e.matches ? "dark" : "light"); });
document.getElementById("themeToggle").addEventListener("click", () => {
const next = root.dataset.theme === "dark" ? "light" : "dark";
apply(next);
save(next);
});
// Tabs
document.querySelectorAll(".tab").forEach(btn => {
btn.addEventListener("click", () => {
document.querySelectorAll(".tab").forEach(b => {
b.classList.toggle("active", b === btn);
b.setAttribute("aria-selected", b === btn);
});
document.querySelectorAll(".panel").forEach(p => {
p.hidden = p.id !== btn.dataset.panel;
});
// editors inside hidden panels sometimes need a nudge to redraw at full size
window.dispatchEvent(new Event("resize"));
});
});
// Width resize
const wrap = document.getElementById("resizeWrap");
const handle = document.getElementById("widthHandle");
const label = document.getElementById("widthLabel");
let startX = 0, startW = 0;
function setWidth(px) {
const max = wrap.parentElement.clientWidth;
const w = Math.max(360, Math.min(px, max));
wrap.style.width = w + "px";
label.textContent = Math.round(w) + " px";
window.dispatchEvent(new Event("resize")); // let the editors re-layout
}
handle.addEventListener("pointerdown", e => {
startX = e.clientX;
startW = wrap.getBoundingClientRect().width;
handle.setPointerCapture(e.pointerId);
wrap.classList.add("resizing");
document.body.classList.add("no-select");
label.textContent = Math.round(startW) + " px";
});
handle.addEventListener("pointermove", e => {
if (!handle.hasPointerCapture(e.pointerId)) return;
// card is centred, so it grows on both sides: x2 keeps the edge under the mouse
setWidth(startW + (e.clientX - startX) * 2);
});
handle.addEventListener("pointerup", e => {
handle.releasePointerCapture(e.pointerId);
wrap.classList.remove("resizing");
document.body.classList.remove("no-select");
});
// Double-click: back to full width
handle.addEventListener("dblclick", () => {
wrap.style.width = "";
window.dispatchEvent(new Event("resize"));
});
Your page's own JavaScript can drive the widgets: put SQL in the editor, run it, point the grid at a table or a query, and read the results back. Every method waits until its widget has started. Rows come back as plain objects keyed by column name: { "id": 1, "status": "paid" }.
// Press Run on an example: it calls the method on the
// playground's widget above and shows what came back.
visualeaf-results
// Every run fires visualeaf-results, the page's and the reader's
// (Run button, paging, sorting). Run something in the playground above.
They can be called as soon as the element is defined (await customElements.whenDefined('visualeaf-sql')); await el.whenReady() waits for the widget to start. The schema designer has no methods.
| Element | Method | What it does |
|---|---|---|
| all three | whenReady() | Resolves once the widget has started (the grid: once its first page has loaded). |
query(sql, {limit}?) | Runs SQL on the widget's database without touching its screen, and resolves with the last statement's {columns, rows, hasMore} (or {rowsAffected} for a write). At most limit rows, default 1000. Rejects with DuckDB's message. | |
<visualeaf-sql> | getScript() / setScript(sql) | The editor's text. Setting it keeps the reader's undo. |
run(sql?, {limit}?) | Runs the editor's script, as ▶ Run does, after putting sql in it when given. Resolves when the run ends: {status, database, schema, statements, totalTime}, status being success, error or stopped. Each statement is {index, sql, status, columns, rows, rowCount, hasMore, rowsAffected, error, errorLine, executionTime}; status is rows (up to limit rows, default 100), affected or error. | |
getResults() | The last run's result, the page's or the reader's (null before the first). | |
<visualeaf-table> | getTable() | {database, schema, table, sql}: the table shown, and the SQL above the grid when there is one. |
setTable(name) | Shows another table of the schema, as the table chooser does. Rejects when there is no such table. | |
run({table?, sql?}?) | Loads the grid's first page, after switching table and putting sql above the grid when given: {database, schema, table, sql, columns, rows, offset, pageSize, hasMore}. Rejects when DuckDB refuses the query. | |
getResults() | The page the grid shows now. | |
<visualeaf-table-manager> | getTable() / setTable(name) | The table whose structure is shown: {database, schema, table}. |
| events | visualeaf-results | On <visualeaf-sql> and <visualeaf-table>, after every run, the page's or the reader's, with the result as detail. |
The desktop app has the same SQL editor, table editor, table management and schema designer, plus charts, explain plans, data compare and more, for DuckDB, PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and more.