---
updatedAt: 2026-06-15T15:24:21.000Z
agentTools:
  projectIndex: https://docs.datastreamer.io/llms.txt
---

# JSON Router

## What Is the Document Router?

The Document Router is a component that directs documents through different paths in a pipeline based on custom filters. It's useful when you need to route documents differently depending on their metadata, structure, or content.

## What is the Message Router? (Advanced Users)

The Message Router works like the Document Router, but it applies routing and filtering at the message level (a message carries on average a hundred documents).

### Key Features

* Route documents using flexible JSON-based filters.
* Supports multiple routes per document.
* Filters use operators like `eq`, `gt`, `exists`, and regex matching.
* Includes both visual builder and raw JSON editor for configuration.

### Getting Started with the JSON Document Router

To use the Document Router:

* **Add the JSON Document Router** to your pipeline.
* Open the component’s configuration panel:

<Image align="center" src="https://files.readme.io/57272719aa3e7b186cf1831bfddfc8608eb1dd3b972166a515a5c8d72bb1890c-Screenshot_2024-09-12_113645.png" />

> 💡 Tip: Allow Multi-route
>
> By default, a document follows **only the first matching route**. Enable **Allow Multi-route** to send the same document through **all routes** that match, including those without filters.

### Routing Table Configuration

Each Document Router contains a **Routing Table** with two configuration layers:

#### 1. Route

* A numbered output path (e.g., 0, 1, 2…).
* By default, routes allow all documents unless a filter is defined.

#### 2. Filter

* Filters define conditions a document must meet to take a given route.
* Filters are evaluated using operators.

<Image align="center" src="https://files.readme.io/bea0e5f8dd0d2688b193f9b3c9222be851410db6bfb3d0c711887929a05dcfe5-Screenshot_2024-09-12_122121.png" />

> 📆 Date Filtering
>
> Date-based filters use relative offsets. For example, you can route documents only if a timestamp field is within the last 7 days.

#### Filter Operators

Operators control how each filter behaves. Here's a list of supported options:

| Operator | Description                                                              |
| :------- | :----------------------------------------------------------------------- |
| `and`    | All nested conditions must be true.                                      |
| `or`     | At least one nested condition must be true.                              |
| `not`    | Inverts a nested condition.                                              |
| `eq`     | Path value equals a specific value.                                      |
| `ne`     | Path value does not equal the value.                                     |
| `gt`     | Path value is greater than the value.                                    |
| `gte`    | Path value is greater than or equal to the value.                        |
| `lt`     | Path value is less than the value.                                       |
| `lte`    | Path value is less than or equal to the value.                           |
| `exists` | JSON path must exist in the document.                                    |
| `match`  | Path matches a regular expression ([test here](https://regex101.com/)) . |

<br />

### Node Inspector

To view a route's filter quickly, hover over its route number in the UI:

<Image align="center" src="https://files.readme.io/9d78fcaaef5e2dcf0241960b6d829fc305c33c05a870765ff47c7907cf83884a-Screenshot_2024-09-12_114220.png" />

### JSON Editor (Advanced Users)

Switch between the **Builder** and **JSON** modes using the `JSON|Builder` toggle.

Use JSON mode to:

* Copy/paste routing configurations across pipelines.
* Make bulk edits or review raw logic.

Avoid writing new routing logic entirely in JSON unless you’re confident in the syntax.

<Image align="center" src="https://files.readme.io/2569bbf1e6aaeda5f7f6ab675d33c21749095cdcfd3757c53d45f3a998d4867d-Screenshot_2024-09-12_122330.png" />

### FAQ

#### Can I route a document through more than one path?

Yes! Enable Allow Multi-route to send documents through all matching routes.

#### What kinds of filters can I create?

You can check for field existence, compare numeric or date values, or even match patterns using regex.

#### Where can I test my regex filters?

Use [regex101.com](https://regex101.com) to test your patterns before using them in the filter.