Home

Overview

DocSlicer turns PDFs, DOCX, PPTX, and HTML into clean, structured chunks — ready to feed into RAG pipelines, LLM agents, or any document-processing workflow. No LLM required.

Most parsers hand you a flat wall of text. DocSlicer preserves the document's inherent structure — headings, sections, tables — and uses that structure to produce semantically coherent chunks that respect natural content boundaries.


The mental model

Every parse returns a single ParseResult. It exposes the document as five views, and almost everything you do with DocSlicer is reading one of them:

  • Blocks — the atomic units DocSlicer extracts: one heading, one paragraph, or one table each. Everything else is built from these.
  • Chunks — consecutive blocks grouped under the same heading and sized to fit an embedding model's context window. This is what you feed to a vector store.
  • Tables — each table extracted once and rendered in your chosen representation (markdown, jsonl, or melted).
  • Charts — embedded charts (DOCX and PPTX) recovered as data, not pixels: one row per plotted point, with series names, categories, values, and axis titles, plus a markdown table of the same data.
  • Hierarchy — the document's heading tree, for navigating long documents by structure rather than by page.

Get the five-object model and the rest of the docs fall into place: the reference pages just document the fields of each.


Supported formats

  • .pdf — layout-aware extraction with table detection
  • .docx — native Open XML parsing, preserves heading levels
  • .pptx — slide-by-slide extraction with layout awareness
  • .html — full JS rendering via Playwright, or a raw HTML string

Quick example

import docslicer
 
result = docslicer.parse_document("contract.pdf")
 
for chunk in result.chunks:
    print(chunk.heading, "—", chunk.text[:80])

parse_document is the entry point for the 95% case — it auto-detects the format from the file extension and magic bytes, so you never branch on type.


When to use which function

  • Mixed or unknown input? Use parse_document — it auto-detects from extension and magic bytes. This is the default.
  • Know the format, and want it to fail loudly on a mismatch? Use parse_pdf, parse_docx, parse_pptx, or parse_html directly.
  • Processing a folder? Use parse_all — it yields (source, result) pairs and never aborts on a single failure.
  • Re-using the same config across many calls? Instantiate a DocumentParser once and call .parse() — it avoids rebuilding the config every time.

Next steps

  • Quickstart — a parsed, chunked document in under 2 minutes
  • Installation — optional extras, Playwright setup, version pinning
  • Blocks — start on the data model