react-querybuilder vs react-awesome-query-builder vs @react-awesome-query-builder/antd
React Query Builder Libraries Comparison
1 Year
react-querybuilderreact-awesome-query-builder@react-awesome-query-builder/antdSimilar Packages:
What's React Query Builder Libraries?

React Query Builder Libraries are tools that allow developers to create complex query builders in React applications. These libraries provide a user-friendly interface for constructing queries, which can then be translated into various formats (like SQL, MongoDB, etc.) for backend processing. They are particularly useful in applications that require advanced filtering, searching, or data manipulation capabilities, such as dashboards, admin panels, or any data-driven application. These libraries often support features like drag-and-drop functionality, dynamic field creation, and customizable query logic, making them versatile tools for enhancing user interaction with data.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-querybuilder74,9191,4877.32 MB2314 days agoMIT
react-awesome-query-builder52,2022,1062.83 MB1252 years agoMIT
@react-awesome-query-builder/antd22,2452,106527 kB1255 days agoMIT
Feature Comparison: react-querybuilder vs react-awesome-query-builder vs @react-awesome-query-builder/antd

Integration with UI Frameworks

  • react-querybuilder:

    react-querybuilder is also framework-agnostic and provides a simple and clean design that can be easily customized. However, it does not offer built-in components for any specific UI library, which means developers will need to style it themselves or integrate it with their chosen framework.

  • react-awesome-query-builder:

    react-awesome-query-builder is framework-agnostic, meaning it does not depend on any specific UI library. This allows for greater flexibility in design, as developers can implement their own styles and components without being constrained by a particular framework.

  • @react-awesome-query-builder/antd:

    @react-awesome-query-builder/antd is specifically designed to integrate with Ant Design, providing components that match the Ant Design style and behavior. This makes it easy to use in projects that already utilize Ant Design, ensuring a consistent look and feel across the application.

Customization and Extensibility

  • react-querybuilder:

    react-querybuilder provides basic customization options, such as changing the appearance of the query builder and defining custom fields and operators. However, it is not as extensible as react-awesome-query-builder, which may limit more advanced customizations.

  • react-awesome-query-builder:

    react-awesome-query-builder offers extensive customization options, including the ability to define your own field types, operators, and styles. It is highly extensible, allowing developers to add new features or modify existing ones to suit their needs.

  • @react-awesome-query-builder/antd:

    @react-awesome-query-builder/antd allows for some level of customization, but it is primarily designed to work with Ant Design components. This means that while you can customize the query builder, it is most effective when used within the constraints of the Ant Design framework.

Complexity and Learning Curve

  • react-querybuilder:

    react-querybuilder is designed to be simple and intuitive, making it easy for developers to quickly understand and use. Its straightforward API and clean design reduce the learning curve, making it a good choice for projects that need a quick and easy solution.

  • react-awesome-query-builder:

    react-awesome-query-builder has a steeper learning curve due to its extensive features and customization capabilities. Developers may need to spend time understanding how to leverage its full potential, especially if they want to implement advanced features or customizations.

  • @react-awesome-query-builder/antd:

    @react-awesome-query-builder/antd has a moderate learning curve, especially for developers who are familiar with Ant Design. The integration with Ant Design components makes it easier to understand and use, but some time may be needed to fully grasp its features and customization options.

Code Example

  • react-querybuilder:

    Example of react-querybuilder Simple Query Builder

    import React from 'react';
    import { QueryBuilder } from 'react-querybuilder';
    import 'react-querybuilder/lib/css/index.css';
    
    const App = () => {
      return (
        <div style={{ padding: '20px' }}>
          <h2>Simple Query Builder</h2>
          <QueryBuilder />
        </div>
      );
    };
    
    export default App;
    
  • react-awesome-query-builder:

    Example of react-awesome-query-builder Customization

    import React from 'react';
    import { QueryBuilder } from 'react-awesome-query-builder';
    import 'react-awesome-query-builder/css/styles.css';
    
    const config = {
      fields: {
        name: { label: 'Name', type: 'text' },
        age: { label: 'Age', type: 'number' },
        email: { label: 'Email', type: 'text' },
      },
    };
    
    const App = () => {
      return (
        <div style={{ padding: '20px' }}>
          <h2>Customizable Query Builder</h2>
          <QueryBuilder config={config} />
        </div>
      );
    };
    
    export default App;
    
  • @react-awesome-query-builder/antd:

    Example of @react-awesome-query-builder/antd Integration with Ant Design

    import React from 'react';
    import { QueryBuilder } from '@react-awesome-query-builder/antd';
    import 'antd/dist/antd.css';
    import '@react-awesome-query-builder/antd/dist/css/styles.css';
    
    const config = {
      fields: {
        name: { label: 'Name', type: 'text' },
        age: { label: 'Age', type: 'number' },
        email: { label: 'Email', type: 'text' },
      },
    };
    
    const App = () => {
      return (
        <div style={{ padding: '20px' }}>
          <h2>Query Builder with Ant Design</h2>
          <QueryBuilder config={config} />
        </div>
      );
    };
    
    export default App;
    
How to Choose: react-querybuilder vs react-awesome-query-builder vs @react-awesome-query-builder/antd
  • react-querybuilder:

    Opt for react-querybuilder if you are looking for a lightweight and easy-to-use query builder that provides basic functionality without a steep learning curve. This package is ideal for projects that need a simple and intuitive query building interface without the need for extensive customization. It is perfect for applications where quick implementation and ease of use are more important than advanced features.

  • react-awesome-query-builder:

    Select react-awesome-query-builder if you need a highly customizable and feature-rich query builder that is not tied to any specific UI framework. This package offers great flexibility in terms of styling and functionality, allowing you to create a query builder that fits your application's unique requirements. It is suitable for projects where you want full control over the design and behavior of the query builder.

  • @react-awesome-query-builder/antd:

    Choose @react-awesome-query-builder/antd if you are building a React application that already uses Ant Design and you want a query builder that seamlessly integrates with Ant Design components. This package provides a visually appealing and consistent UI that matches the Ant Design aesthetic, making it ideal for projects that prioritize design consistency and user experience.

README for react-querybuilder

react-querybuilder

The Query Builder component for React

React Query Builder is a fully customizable query builder component for React, along with a collection of utility functions for importing from, and exporting to, various query languages like SQL, MongoDB, and more.

Screenshot

Basic usage

npm i react-querybuilder
# OR yarn add / pnpm add / bun add
import { useState } from 'react';
import { Field, QueryBuilder, RuleGroupType } from 'react-querybuilder';
import 'react-querybuilder/dist/query-builder.css';

const fields: Field[] = [
  { name: 'firstName', label: 'First Name' },
  { name: 'lastName', label: 'Last Name' },
  { name: 'age', label: 'Age', inputType: 'number' },
  { name: 'address', label: 'Address' },
  { name: 'phone', label: 'Phone' },
  { name: 'email', label: 'Email', validator: ({ value }) => /^[^@]+@[^@]+/.test(value) },
  { name: 'twitter', label: 'Twitter' },
  { name: 'isDev', label: 'Is a Developer?', valueEditorType: 'checkbox', defaultValue: false },
];

const initialQuery: RuleGroupType = {
  combinator: 'and',
  rules: [],
};

export const App = () => {
  const [query, setQuery] = useState(initialQuery);

  return <QueryBuilder fields={fields} defaultQuery={query} onQueryChange={setQuery} />;
};

Customizations are not limited to the following libraries, but these have first-class support through their respective compatibility packages:

| Library | Compatibility package | Demo | Example projects | | -------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | Ant Design | @react-querybuilder/antd | demo | CodeSandbox · StackBlitz | | Bootstrap | @react-querybuilder/bootstrap | demo | CodeSandbox · StackBlitz | | Bulma | @react-querybuilder/bulma | demo | CodeSandbox · StackBlitz | | Chakra UI | @react-querybuilder/chakra | demo | CodeSandbox · StackBlitz | | Fluent UI | @react-querybuilder/fluent | demo | CodeSandbox · StackBlitz | | Mantine | @react-querybuilder/mantine | demo | CodeSandbox · StackBlitz | | MUI | @react-querybuilder/material | demo | CodeSandbox · StackBlitz | | React Native | @react-querybuilder/native | | CodeSandbox · StackBlitz | | Tremor | @react-querybuilder/tremor | demo | CodeSandbox · StackBlitz |

[!TIP]

To enable drag-and-drop, use @react-querybuilder/dnd.

For enhanced date/time support, use @react-querybuilder/datetime.

Export

To export queries as a SQL WHERE clause, MongoDB query object, or one of several other formats, use formatQuery.

const query = {
  combinator: 'and',
  rules: [
    {
      field: 'first_name',
      operator: 'beginsWith',
      value: 'Stev',
    },
    {
      field: 'last_name',
      operator: 'in',
      value: 'Vai, Vaughan',
    },
  ],
};

formatQuery(query, 'sql');
/*
"(first_name like 'Stev%' and last_name in ('Vai', 'Vaughan'))"
*/

Import

To import queries use parseSQL, parseMongoDB, parseJsonLogic, parseJSONata, parseCEL, or parseSpEL depending on the source.

// Tip: `parseSQL` will accept either a full `SELECT` statement or a `WHERE` clause by itself.
// Everything but the `WHERE` expressions will be ignored.

const query = parseSQL(
  `SELECT * FROM my_table WHERE first_name LIKE 'Stev%' AND last_name in ('Vai', 'Vaughan')`
);

console.log(query);
/*
{
  "combinator": "and",
  "rules": [
    {
      "field": "first_name",
      "operator": "beginsWith",
      "value": "Stev",
    },
    {
      "field": "last_name",
      "operator": "in",
      "value": "Vai, Vaughan",
    },
  ],
}
*/

Utilities

formatQuery, transformQuery, and the parse* functions can be used without importing from react (on the server, for example) like this:

import { formatQuery } from 'react-querybuilder/formatQuery';
import { parseCEL } from 'react-querybuilder/parseCEL';
import { parseJSONata } from 'react-querybuilder/parseJSONata';
import { parseJsonLogic } from 'react-querybuilder/parseJsonLogic';
import { parseMongoDB } from 'react-querybuilder/parseMongoDB';
import { parseSpEL } from 'react-querybuilder/parseSpEL';
import { parseSQL } from 'react-querybuilder/parseSQL';
import { transformQuery } from 'react-querybuilder/transformQuery';

(As of version 7, the parse* functions are only available through these extended exports.)