Svelte query builder

An open-source query builder for Svelte 5. bind:value in, typed query out, with undo, drag and drop, validation and export to SQL, MongoDB and JsonLogic.

MIT · Svelte 5 · runes · TypeScript

@qnot/svelte, default builder, live on this page. Edit a rule and watch the exports.

installpnpm add @qnot/core @qnot/svelte

A Svelte query builder in two files.

The fields you can query, and the component that edits them. It's the code behind the demo above, minus the export tabs.
fields.ts
Filters.svelte

For more control, put a store in context with setQueryStore and read it with getQueryStore. The create* helpers (createRule, createGroup, createQuery, createHistory) each subscribe only to the node they read, so editing one rule updates one rule.

The default builder takes components, labels and class. See the Svelte guide.

What you get.

Everything below works in every binding, because it lives in the store, not the components.

How it compares.

Most Svelte query builders you'll find come inside commercial component suites. Below, their JavaScript builds against qnot's framework-free build on the same 1,000-rule tree. The Svelte binding has its own numbers.

Questions people ask

Is it free?
Yes. @qnot/svelte and @qnot/core are MIT licensed, with no license key, no trial banner and no paid tier.
Which Svelte versions are supported?
Svelte 5. The components use runes, and the reactive helpers subscribe once per node, so an edit only wakes the rows it changes.
Does it work with SvelteKit?
Yes. The package ships .svelte source through the svelte export condition, which SvelteKit's Vite plugin compiles. The default builder renders on the server (we checked it with svelte/server's render), and your +server.ts or form actions can import the same fields.ts to validate the query and turn it into SQL.Server usage
Does it support bind:value?
Yes. QueryBuilder takes value as a bindable prop, plus onchange. You can also pass a store you created and share it with setQueryStore.
Can I write my own components?
Yes. createRule, createGroup, createQuery, createHistory and the drag helpers return objects whose getters subscribe only to what they read. They work in components and in .svelte.ts modules. The default Group, Rule and ValueEditor are exported for reuse.Svelte guide
Can the same query run on the server?
Yes. The query is plain JSON typed by your schema. On the server, validate it with validateQuery, then encode it to parameterized SQL, a MongoDB filter or JsonLogic, or filter rows in memory with compile.Formats