> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Character Splitter

> Split text based on a single character separator

## Overview

Character splitter splits text using a single, specified separator. Ideal for documents with clear and consistent delimiters. Uses a direct "Split and Merge" process for efficiency and positional integrity.

**Splitter Class:** `CharacterChunker`

**Config Class:** `CharacterChunkingConfig`

## Dependencies

No additional dependencies required. Uses standard library.

## Examples

```python theme={null}
from upsonic import Agent, Task, KnowledgeBase
from upsonic.loaders.text import TextLoader
from upsonic.loaders.config import TextLoaderConfig
from upsonic.embeddings import OpenAIEmbedding, OpenAIEmbeddingConfig
from upsonic.text_splitter.character import CharacterChunker, CharacterChunkingConfig
from upsonic.vectordb import ChromaProvider, ChromaConfig, ConnectionConfig, Mode

# Configure splitter
splitter_config = CharacterChunkingConfig(
    chunk_size=512,
    chunk_overlap=50,
    separator="\n\n"
)
splitter = CharacterChunker(splitter_config)

# Setup KnowledgeBase
loader = TextLoader(TextLoaderConfig())
embedding = OpenAIEmbedding(OpenAIEmbeddingConfig())
vectordb = ChromaProvider(ChromaConfig(
    collection_name="character_docs",
    vector_size=1536,
    connection=ConnectionConfig(mode=Mode.IN_MEMORY)
))

kb = KnowledgeBase(
    sources=["document.txt"],
    embedding_provider=embedding,
    vectordb=vectordb,
    loaders=[loader],
    splitters=[splitter]
)

# Query with Agent
agent = Agent("anthropic/claude-sonnet-4-5")
task = Task("What are the key sections?", context=[kb])
result = agent.do(task)
print(result)
```

## Parameters

| Parameter | Type | Description | Default | Source |
| - | - | - | - | - |
| `chunk_size` | `int` | Target size of each chunk | 1024 | Base |
| `chunk_overlap` | `int` | Overlapping units between chunks | 200 | Base |
| `min_chunk_size` | `int \| None` | Minimum size for a chunk | None | Base |
| `length_function` | `Callable[[str], int]` | Function to measure text length | `len` | Base |
| `strip_whitespace` | `bool` | Strip leading/trailing whitespace | False | Base |
| `separator` | `str` | Single separator string or regex | `"\n\n"` | Specific |
| `is_separator_regex` | `bool` | Treat separator as regex | False | Specific |
| `keep_separator` | `bool` | Keep separator in chunks | True | Specific |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.