---
title: Text Classifier
description: Classify text into one of a set of given categories using a LLM, or on-device with a Local Classifier
---

Put a text into one of the categories you list, with a chat model or on-device.

## Try it

## What it does

Text Classifier reads **Text** and returns the best matching category from **Categories** in `category`. What you connect to **Model** decides how; there is no setting to switch:

* **A chat model** (for example [Chat OpenAI](/nodes/builtin/ai/aidependencies/llm/openai/) or [Web LLM](/nodes/builtin/ai/aidependencies/llm/wbellm/)) is told to answer with exactly one category name and nothing else, or `unknown` when none fits.
* **A [Local Classifier](/nodes/builtin/ai/aidependencies/llm/localclassifier/)** runs in your browser: free, private and offline. With a zero-shot model, your **Categories** are scored and the best one wins. With a fixed-label model (sentiment, toxicity), the model's own labels are used and **Categories** is ignored. **System message** does not apply.

The node has one output. To send each category down its own path, follow it with a [Switch](/nodes/builtin/flow/switch/).

## When to use it

* Sort support requests into `billing, technical, sales` and route each to the right team.
* Tag articles or emails by topic before you save them.
* Detect the intent of a chat message (`question, complaint, order`).

To label tone only, use [Sentiment Analysis](/nodes/builtin/ai/aiagents/sentimentanalysisnode/). To classify on-device without a model node, use [Classify Text](/nodes/builtin/ai/localai/classify-text/).

## Inputs and settings

Fill **Text** with an expression such as `{{ $input.text }}`. Write **Categories** as a comma-separated list, for example `billing, technical, sales`. Short, clearly different names give the most reliable results. Use **System message** to describe a category when its name alone is ambiguous, such as `"sales" means questions about buying or pricing.`

## Outputs

Each output item has these fields:

```json title="Shape of an output item"
{
  "category": null,
  "scores": {}
}
```

`category` is one of your category names, or `unknown` when none fits (or when the on-device model returns no label). `scores` is only there with a Local Classifier.

## Dependencies and credentials

Connect a chat model, which holds its own API key, or a [Local Classifier](/nodes/builtin/ai/aidependencies/llm/localclassifier/) with a zero-shot model to classify on-device with your own categories.

## Example workflow

1. [Get Selected Text](/nodes/extension/getselectedtext/) reads a support email you highlighted, with **Output field name** `text`.
2. Text Classifier with **Text** `{{ $input.text }}` and **Categories** `billing, technical, sales`, with an [Chat OpenAI](/nodes/builtin/ai/aidependencies/llm/openai/) model on **Model**.
3. [Switch](/nodes/builtin/flow/switch/) in **Rules** mode with one rule per category, each checking that `{{ $input.category }}` equals the category name, and **Add A Fallback Branch** on for `unknown`.
4. Each branch posts to a different [Slack](/nodes/builtin/integration/slack/) channel.

## Common issues

* **`category` is often `unknown`.** Your categories do not cover the texts you receive, or the names are vague. Add a category, or explain them in **System message**.
* **The category does not match your Switch rules.** A chat model may change the capitalisation or add words. Add `Answer with the category name exactly as written.` in **System message**.
* **"Add at least one category: the zero-shot classifier scores the text against them."** A zero-shot Local Classifier is connected and **Categories** is empty.
* **"Model not found".** The connected chat model node is not set up: open it and choose a model and its credential.

## Related nodes

* [Switch](/nodes/builtin/flow/switch/): send each category down its own path.
* [Sentiment Analysis](/nodes/builtin/ai/aiagents/sentimentanalysisnode/): label tone.
* [Classify Text](/nodes/builtin/ai/localai/classify-text/): on-device classification without a model node.
* [Local Classifier](/nodes/builtin/ai/aidependencies/llm/localclassifier/): the on-device model for this node.