React Query Builder: A flexible rule editor with export paths for SQL and MongoDB
Project brief: The Query Builder component for React. [!TIP] To enable drag-and-drop, use @react-querybuilder/dnd.
At a glance
- What is it?
- React Query Builder is a TypeScript component for building nested query rules in React, with official adapters for popular UI libraries and utilities to convert queries to SQL, MongoDB, and other formats. Its strength is customization, but that flexibility comes with a learning curve and a need to manage your own state.
- Who is it for?
- Adopt React Query Builder if you need a customizable, UI-agnostic rule editor in React and you are willing to invest time in learning its schema and state model. Skip it if you want a turnkey widget with minimal configuration or if your queries are simple enough to hard-code.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 16, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What problem it solves and who it is for
The component is built with TypeScript and distributed as an npm package. The core package is react-querybuilder, and it ships with a default stylesheet that you import explicitly. The documentation mentions a demo at react-querybuilder.js.org/demo, which is where you can see the default look. The intended audience is developers who have a non-trivial filtering or reporting feature and who prefer to reuse a battle-tested logic layer rather than write their own rule tree state management from scratch.
The core mechanism: a query tree and controlled state
The tree structure is recursive. A group can contain other groups, which allows arbitrary nesting depth. The component's job is to render that tree and to provide UI controls for adding, removing, and editing rules. The actual logic of evaluating the query against data is not in the core package. Instead, the project provides utility functions for importing from and exporting to query languages. That is a deliberate split: the component manages the UI, and the utilities handle conversion.
Getting it running: installation and first render
The compatibility packages are separate npm packages, one per UI library: @react-querybuilder/antd, @react-querybuilder/bootstrap, @react-querybuilder/bulma, @react-querybuilder/chakra, @react-querybuilder/fluent, @react-querybuilder/mantine, @react-querybuilder/material, @react-querybuilder/prime, @react-querybuilder/tremor, and @react-querybuilder/native for React Native. These packages provide components that use the specific library's form controls and styling. You would install the one that matches your project. For example, if you use Material UI, you install @react-querybuilder/material. The README also lists optional enhancers: @react-querybuilder/dnd for drag-and-drop, @react-querybuilder/datetime for date/time pickers, @react-querybuilder/expr for expressions in rules, and @react-querybuilder/rules-engine for if-then-else logic. These are separate packages you add only if you need those features.
Export and import: the bridge to SQL and MongoDB
The conversion is not a magic bullet. SQL and MongoDB have different capabilities. A SQL query might use a JOIN, which a rule tree cannot represent. The utility functions likely handle only a subset of each language, specifically the parts that map to a boolean rule tree. You should test whether your existing queries round-trip correctly. The documentation likely lists the supported operators and value types. If your queries use exotic functions or nested subqueries, they may not convert cleanly.
Limitations and cases where it is the wrong tool
Third, the component is React-only. If you are not using React, this is irrelevant. Fourth, the drag-and-drop feature is not in the core package; you must install @react-querybuilder/dnd. That is an extra dependency and an extra learning step. Fifth, the default stylesheet is minimal. If you want a polished UI, you will likely need to use a compatibility package or write custom styles. The component's flexibility means you have to build the look you want. For teams that want a quick, out-of-the-box widget, this is a barrier. Also, the component is controlled, so you must manage the query state in your own code. If you forget to pass onQueryChange or fail to update the state, the UI will not respond to user input. That is a common pitfall.
Alternatives: React Awesome Query Builder and writing your own
The migration guide from RAQB suggests that the two projects are similar enough that moving between them is a real consideration. That is a sign that the ecosystem has competing solutions. When choosing, consider whether you value a smaller core with opt-in packages (react-querybuilder) versus a more monolithic component (RAQB). Also check the maintenance status of each project, but do not judge solely on star counts.
Maintenance, upgrades, and license
The repository includes a contribution guide, and the README lists a training course by the maintainer, which indicates a sustained investment in documentation. The documentation site is comprehensive, with sections for intro, utils, and migration. That is a positive sign for maintainability. The cost of maintenance for you as a user is the time to learn the component's API and to configure it for your fields. That cost is front-loaded. Once configured, the component handles the tree logic, and you benefit from bug fixes and new features as long as you track releases.
Editorial conclusion
Adopt React Query Builder if you need a customizable, UI-agnostic rule editor in React and you are willing to invest time in learning its schema and state model. Skip it if you want a turnkey widget with minimal configuration or if your queries are simple enough to hard-code. Before committing, verify that the current version (v8.23.1 as of August 2026) supports your React version and that the compatibility package for your chosen UI library (for example @react-querybuilder/material) is maintained. Also check the migration guide if you are upgrading from an earlier release, because the project has a documented history of breaking changes.
Community notes