DEV Community

Cover image for Query CSV, Excel, Parquet, and Arrow files in the Browser with DuckDB-Wasm + Next.js πŸ¦†βœ¨

Query CSV, Excel, Parquet, and Arrow files in the Browser with DuckDB-Wasm + Next.js πŸ¦†βœ¨

I recently built a browser-based SQL tool in my portfolio site: DataBro SQL Query Tool πŸš€

It lets you load local files, run SQL directly in the browser, and explore data without sending the raw file to a backend first. That idea felt too interesting not to write aboutβ€”because once you see DuckDB-Wasm in action, the browser starts looking a lot less like a UI shell and a lot more like a tiny analytics engine πŸ¦†βœ¨

What if a browser tab could become a tiny analytics engine? 🀯 DuckDB-Wasm brings DuckDB into the browser through WebAssembly, which means a web app can run analytical SQL locally on the user's machine instead of sending every file to a backend first.

That one idea changes a lot. In the tool above, a Next.js SPA can let users upload CSV, Excel, Parquet, and Arrow and run SQL instantly while keeping the raw data private in the browser session πŸ”’

This post walks through that pattern using my portfolio tool as the exampleβ€”a Next.js app that behaves like a lightweight local data workbench, powered by DuckDB-Wasm and browser-side file processing.

What is DuckDB-Wasm? πŸ¦†

DuckDB-Wasm is the browser-friendly version of DuckDB, compiled to WebAssembly so it can run analytical SQL inside a web app.

Instead of treating the browser as a thin UI layer, it turns the browser into a place where real data work can happen.

That is the part that sparks curiosity. Most people expect SQL engines to live on servers, behind APIs, databases, and cloud infrastructure. DuckDB-Wasm flips that assumption by letting a user open a page, load a file, and query it locally in the same environment where the UI is rendered.

In practical terms, this means a browser app can feel surprisingly close to a desktop analytics tool. It can scan files, preview structured data, run aggregation queries, and return results quickly without forcing users through an upload-first workflow.

Why this is exciting for web apps ⚑

Most web apps that handle tabular data follow the same pattern: upload the file, store it temporarily, process it on the server, then return a preview.

That works, but it introduces latency, backend complexity, and privacy concerns.

With DuckDB-Wasm, a lot of that flow can move directly into the browser. That means less infrastructure for exploratory data tasks and a much better experience for one-off analysis, internal tools, and privacy-sensitive workflows.

It also creates a more delightful product experience. In my tool, you can load a file and ask it questions with SQL immediatelyβ€”that feels more like magic than middleware ✨

The privacy angle is the real story πŸ”

Speed is nice, but privacy is the bigger win.

When DuckDB-Wasm runs in the browser, the SQL engine runs locally alongside the UI. In my app, uploaded files are handled inside the client-side page, registered locally for querying, and processed without requiring a traditional server-side query path.

That makes this pattern especially attractive for sensitive exports, spreadsheets with internal business data, quick inspections of customer-provided files, and any workflow where users do not want to upload raw datasets to a remote service just to answer a few SQL questions.

A good line to emphasize here:

Your browser is not just rendering the UIβ€”it is running the SQL privately on your machine πŸ§ πŸ”’

That idea is what makes readers pause.

How different file types become queryable πŸ“‚

One of the most interesting engineering details in the tool is that not every file format takes the same route into SQL.

CSV takes the simplest path: register the file and query it with DuckDB using automatic CSV detection. Excel is parsed in the browser first and transformed into a query-friendly structure before being registered for SQL access. Parquet can be queried more directly, while Arrow and Avro can go through browser-side transformations before querying.

This creates a good teaching moment: the UI can feel simple and unified even when the ingestion logic is format-specific under the hood. That contrast is exactly the kind of detail that makes technical readers keep scrolling πŸ˜„

Why a Next.js SPA is a great fit πŸš€

This project is also a nice example of how capable a client-side Next.js page can be.

The same page can handle file upload, SQL editing, query execution, result rendering, and browser-side file processing without needing a heavy backend for the core experience.

For developers building internal tools, this is the exciting part. A SPA can start to feel like desktop-grade software when paired with browser-native processing and DuckDB-Wasm, opening the door to private data inspectors, validation tools, and self-serve analytics experiences.

Conclusion 🎯

DuckDB-Wasm makes a Next.js SPA feel surprisingly powerful. A local file can become a queryable dataset in seconds, and the most interesting part is not just the SQLβ€”it is the fact that the work can stay private inside the browser.

That makes this pattern more than a fun demo. It is a practical blueprint for building modern data tools that feel fast, useful, and much easier to trust.

If you want to see the idea in action, here is the tool again: DataBro SQL Query Tool

Top comments (0)