Character Text Splitter Not Splitting Text with \n### Separator

Describe the problem/error/question

I am building a RAG workflow to load a Markdown file into a Supabase vector store. The Markdown file is structured with ### headings for each term.

I am trying to use the Character Text Splitter node to split the document into chunks, using \n### as the separator. However, the node is not splitting the text and is outputting the entire document as a single chunk. This is causing an “input length exceeds maximum context length” error in the downstream Embeddings Ollama node.

I have tried setting the separator in both ‘fixed’ mode and as a JavaScript expression ('\n### '), but neither is working.

What is the error message (if any)?

Error in sub-node ‘Embeddings Ollama’: input length exceeds maximum context length

Please share your workflow

Share the output returned by the last node

(Note: Below is the output of the ‘Character Test Splitter’ node.)

[
{
“response”: [
“# CIPS_Terms_Glossary_Details\n\n## A\n\n### A priori prioritisation\n‘A priori’ means ‘from before’ and a priori prioritisation uses knowledge of what already exists to manage priorities\n\n### ABC analysis\nA simplistic segmentation approach based loosely on Pareto analysis. ABC analysis can be used to breakdown an organisation’s total external spend based on value so its resources are used to manage these expenditures and prioritised accordingly.\n\n### ABC categorisation\nWhen items are grouped into categories in order of importance – A is most important, B less important and C least important”
]
}
]

Information on your n8n setup

  • n8n version: 1.113.1
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via: Docker
  • Operating system: Ubuntu

Hi,
You may try to change the text splitter separator from \n### to just ### (without \n)

The backtick string in your JavaScript already contains real newlines, so \n### is looking for the literal text “\n###” instead of a newline character followed by ###.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.