RagChunk: Semantic RAG Splitter & Markdown Cleaner avatar

RagChunk: Semantic RAG Splitter & Markdown Cleaner

Pricing

$2.00 / 1,000 results

Go to Apify Store
RagChunk: Semantic RAG Splitter & Markdown Cleaner

RagChunk: Semantic RAG Splitter & Markdown Cleaner

Extract, clean, and semantically split documentation URLs into token-safe chunks for Vector DBs. Built-in HTML boilerplate stripping saves up to 40% on LLM token costs.

Pricing

$2.00 / 1,000 results

Rating

0.0

(0)

Developer

FlareTool

FlareTool

Maintained by Community

Actor stats

0

Bookmarked

3

Total users

2

Monthly active users

4 months ago

Last modified

Features

Limited permissions

Share

⚡ RAG Semantic Document Chunker & HTML Cleaner

The only RAG preprocessing tool that thinks like a developer and charges like a cloud function.

Transform any public documentation URL into clean, token-precise, context-rich Markdown chunks, ready to be dropped directly into OpenAI, Pinecone, Weaviate, Chroma, LangChain, or any LLM pipeline. No headless browsers. No bloated DOM trees. No wasted tokens.


🤔 What Problem Does This Solve?

If you have ever tried to build a RAG (Retrieval-Augmented Generation) pipeline on real-world documentation, you already know the pain:

  • You scrape a documentation page and your markdown output is 60% navigation links, sidebar menus, cookie banners, and footer noise, none of which helps your LLM.
  • You try to chunk the raw text but end up slicing code blocks in half, breaking tables mid-row, or losing which section a chunk belongs to.
  • You burn $15 to $40 in OpenAI embedding tokens per document ingestion run because you are vectorizing sidebar garbage instead of actual content.

This Actor solves all three problems in a single API call.


🚀 The Differentiator: Up to 40% Token Savings

Standard scrapers ingest entire DOM trees, wasting thousands of dollars on navigation menus, footers, and tracking scripts. This engine runs an advanced Cheerio-based selector priority extraction cascade and link-density evaluation engine to strip layout noise before any chunking occurs.

Live Validation Benchmark (Node.js API Reference Page):

MetricValue
Raw Markdown Volume395,669 characters
Post-Processed Clean Markdown333,964 characters
Net Token Savings61,705 characters (approximately 15,000 to 20,000 wasted tokens eliminated)

That is real money saved on every single document you ingest.


✅ Who Is This For?

This tool is built for:

  • AI Engineers building RAG pipelines on top of GPT-4, Claude, Gemini, or open-source LLMs.
  • Developer Tool Teams ingesting API reference documentation into vector databases.
  • Startups & SaaS companies building documentation search, AI assistants, or knowledge base copilots.
  • Data engineers automating content ingestion workflows into Pinecone, Weaviate, Chroma, or pgvector.

If you are feeding documentation into a vector database, this is the highest-quality, lowest-cost preprocessing layer available on the market.


✨ Core Engine Features

🧹 Aggressive Boilerplate Sanitization

Removes navigation menus, sidebars, footers, tracking pixels, cookie banners, and advertisement containers using a multi-layer Cheerio-based DOM cascade before any conversion to Markdown occurs. Unlike raw scrapers that hand you the entire DOM, we hand you only the signal.

🛡️ Code Block Integrity Protection

The chunker tracks open and closed Markdown code fences (```) in real-time. If a split would slice a code block in half, it automatically postpones the split until the fence closes. Your LLM will always receive complete, syntactically valid code samples.

📊 Markdown Table Integrity Protection

Tables carry structured data (such as parameter schemas, API response mappings, and comparison grids). Our engine detects table boundaries and applies a configurable table_hard_multiplier budget to keep entire tables within a single chunk, preventing broken header rows from stranding orphaned data rows in the next chunk.

🏷️ Multi-Header Context Tracking

Every emitted chunk includes a header_contexts array listing all active parent headings within the sliding window boundary. When your RAG retriever returns a chunk about reduce(), it will know whether that chunk came from Parameters, Description, or Edge cases. This eliminates the context-drift problem permanently.

🪙 Exact BPE Token Tracking

Uses the cl100k_base Byte Pair Encoding tokenizer, which is the exact same tokenizer used internally by GPT-4 and GPT-4o, to count tokens with 100% accuracy. No approximations. No character-based guesses. Every chunk respects the token ceiling you configure.

⛓️ Cascading Line Segmentation

Handles dense layouts (such as blog indexes, link lists, or documentation menus) that render thousands of characters onto a single line. The parser automatically cascades down through sentence boundaries, list boundaries, semicolon/comma clauses, and word limits to segment long lines below max_tokens * 0.8. This prevents runaway chunk overlaps and ensures strict token bounds.

🔁 Configurable Sliding Overlap Window

Carries a configurable number of trailing tokens from the previous chunk into the next, ensuring that semantic ideas which straddle chunk boundaries are never completely lost during vector retrieval.


📥 Input Configuration

ParameterTypeDefaultDescription
urlstringrequiredThe exact public URL to scrape, extract, and chunk.
max_tokensinteger500Max BPE tokens per chunk (50–2000).
overlapinteger50Trailing overlap tokens between consecutive chunks (0–500).
contentSelectorstringnoneOptional CSS selector to target specific content containers (e.g. main, article, #content).
min_token_floorinteger30Minimum token count to emit a chunk. Discards tiny non-semantic fragments (5–500).
prose_hard_multipliernumber1.2Hard token budget multiplier for prose segments before splitting (1.0–2.0).
table_hard_multipliernumber3.0Hard token budget multiplier inside tables to prevent row fragmentation (1.5–5.0).

Example Input

{
"url": "https://docs.stripe.com/api/payment_intents",
"max_tokens": 400,
"overlap": 40,
"contentSelector": "main"
}

📤 Output Payload

Each Actor run returns a structured JSON dataset where every item is one semantically-clean chunk:

[
{
"chunk_index": 0,
"token_count": 387,
"header_contexts": [
"Payment Intents API",
"Create a PaymentIntent"
],
"content": "## Create a PaymentIntent\n\nCreates a PaymentIntent object.\n\n### Parameters\n\n| Parameter | Type | Description |\n|---|---|---|\n| `amount` | integer | Amount intended to be collected..."
},
{
"chunk_index": 1,
"token_count": 412,
"header_contexts": [
"Create a PaymentIntent",
"Returns"
],
"content": "Returns a PaymentIntent object if the call succeeded. Returns an error if something goes wrong..."
}
]

Output Fields Explained:

  • chunk_index: Sequential position of the chunk within the document.
  • token_count: Exact BPE token count of this chunk's content.
  • header_contexts: All active section headings that were open when this chunk was emitted.
  • content: The clean, pristine GFM Markdown content ready for embedding.

🧪 Validated Against 50+ Real-World Documentation Sites

We stress-tested this engine against a comprehensive 50-URL live matrix covering Wikipedia, MDN, technical docs (React, AWS, Stripe), personal blogs (Paul Graham), forums (Stack Overflow), and company landing pages (Hugging Face, Google DeepMind, Microsoft Research). It achieved:

  • 100% execution success across all accessible layouts.
  • 0 broken code blocks or table rows (100% formatting preservation).
  • Runaway overlap prevention on complex dense lists.

Live Metrics Highlight:

Target URL / Layout TypeClean MarkdownChunks GeneratedMin TokensMax TokensAvg TokensCode Block Integrity
Wikipedia: Retrieval-augmented generation25,214 chars33101480353✅ PASS
Wikipedia: Transformer Architecture184,897 chars281117679402✅ PASS
MDN: Array.prototype.reduce()17,763 chars14328510399✅ PASS
Technical Doc: React useEffect Reference44,352 chars36217501367✅ PASS
Personal Blog: How to Do Great Work (Paul Graham)69,016 chars4565472408✅ PASS
Stripe API: PaymentIntents Reference21,182 chars2770689401✅ PASS
Forum: Stack Overflow Sorted Array Q&A140,564 chars14155584346✅ PASS
Company Blog: Astro Blog (Astro 4 Release)11,871 chars8312437380✅ PASS
Aggregator: Hugging Face Blog Homepage11,698 chars16183579428✅ PASS

⚙️ Performance Benchmarks

MetricValue
Median Latency (p50)~497ms end-to-end
Scraping EngineLightweight DOM parsing (no headless browser)
Token Trackingcl100k_base BPE (GPT-4/GPT-4o compatible)
Memory FootprintResource-isolated, no persistent storage
Pricing$2.00 / 1,000 chunks (pay-per-result, not per-run)

❓ Frequently Asked Questions

Q: What types of pages does this work best on? A: It excels on developer documentation, API reference pages, technical guides, blog articles, and knowledge base content. Any structured, text-rich public web page.

Q: Does it work on sites protected by Cloudflare or other bot protections? A: The engine uses a multi-tier fetch pipeline. If direct access is blocked, it automatically falls back to a secondary content extraction layer to maximize success rates.

Q: How is this priced? A: You pay $2.00 per 1,000 chunks generated. A typical documentation page generates 8–15 chunks, meaning a full page costs less than $0.03. There are no monthly minimums, no seat fees, and no API key commitments.

Q: Can I use this to ingest private/internal documentation? A: This Actor only fetches publicly accessible URLs. It cannot bypass authentication or access pages behind a login wall.

Q: Which vector databases does the output work with? A: The output is plain JSON with string content fields. It is compatible with every major vector database including Pinecone, Weaviate, Chroma, Qdrant, pgvector, Milvus, and any LangChain / LlamaIndex embedding pipeline.

Q: Does it preserve code examples from documentation? A: Yes. This is one of its core differentiators. The engine specifically detects and protects Markdown code fences, refusing to split a chunk mid-code-block regardless of token budget.


Copyright © 2026. All Rights Reserved. Private Proprietary Software. Usage is strictly governed by the Terms of Service and Privacy Policy.