# Quick Start

Chunk any document, stream large files, and convert to Markdown — in Python, JavaScript, or Rust.

Every code block on this page is language-aware — use the tabs (or the global
  switcher in the nav) to see Python, JavaScript, or Rust.

## Batch chunking

Pass a source and, optionally, a `mode`. Each chunk has `content`, a typed
`content_type`, and `metadata`.

```python
from py_chunks import get_chunks, stream_chunks, get_markdown

# Batch — works for every supported format
chunks = get_chunks("document.pdf")
chunks = get_chunks("notes.md",  mode="semantic")
chunks = get_chunks("deck.pptx", mode="sliding_window", window_size=3, overlap=1)

for chunk in chunks:
    print(chunk["content"], chunk["content_type"], chunk["metadata"])

# Streaming — constant memory over huge files
for chunk in stream_chunks("large.pdf", mode="section"):
    handle(chunk)

# Markdown conversion
md = get_markdown("report.docx")
```

```ts
import { getChunks, streamChunks, getMarkdown } from "js-chunks";

// Batch — works for every supported format
let chunks = await getChunks("./document.pdf");
chunks = await getChunks("./notes.md",  { mode: "semantic" });
chunks = await getChunks("./deck.pptx", { mode: "sliding_window", windowSize: 3, overlap: 1 });

for (const c of chunks) {
  console.log(c.content, c.contentType, c.metadata);
}

// Streaming — constant memory over huge files
for await (const chunk of streamChunks("./large.pdf", { mode: "section" })) {
  handle(chunk);
}

// Markdown conversion
const md = await getMarkdown("./report.docx");
```

```rust
use chunks_rs::{get_chunks, get_markdown};

// Batch — dispatch by extension. Positional args:
// get_chunks(path, mode, window_size, overlap, sentences_per_chunk, paragraphs_per_page)
let chunks = get_chunks("document.pdf", "default", 3, 1, 3, 15)?;
let chunks = get_chunks("notes.md",     "semantic", 3, 1, 3, 15)?;

for c in &chunks {
    println!("[{}] {}", c.content_type, c.content);
    // c.metadata is a serde_json::Value with format-specific provenance
}

// Streaming yields the same chunks, one at a time
use chunks_rs::formats::csv;
for c in csv::stream("data.csv", "row", 10, 5, 1, true, None, "utf-8", true)? {
    let c = c?;
}

// One-shot Markdown conversion
let md = get_markdown("report.docx")?;
```

## Streaming

Yield chunks one at a time with constant memory — ideal for large files or
streaming HTTP responses. Which modes stream and their per-format memory profile
are in [Streaming](/docs/streaming).

```python
from py_chunks import stream_chunks

# Constant memory — yields one chunk at a time
for chunk in stream_chunks("data.csv", mode="row"):
    handle(chunk)
```

```ts
import { streamChunks } from "js-chunks";

// Async iterable — one chunk at a time
for await (const chunk of streamChunks("./data.csv", { mode: "row" })) {
  handle(chunk);
}
```

```rust
use chunks_rs::formats::csv;

// stream() is a native Iterator yielding Result<Chunk>
for c in csv::stream("data.csv", "row", 10, 5, 1, true, None, "utf-8", true)? {
    let c = c?;
    handle(c);
}
```

## Markdown conversion

Convert any supported document to a Markdown string.

```python
from py_chunks import get_markdown

md = get_markdown("report.docx")           # -> str
md = get_markdown(file_bytes, filename="report.pdf")  # bytes also supported
```

```ts
import { getMarkdown } from "js-chunks";

const md = await getMarkdown("./report.docx");   // -> string
```

```rust
use chunks_rs::get_markdown;

let md = get_markdown("report.docx")?;     // -> String
```

## Image extraction

Ask for embedded images alongside the chunks.

```python
from py_chunks import get_chunks, ChunksResult

result = get_chunks("deck.pptx", list_images=True)   # -> ChunksResult
result.chunks   # text chunks + image chunks (content_type="image")
result.images   # {"<hash>.jpeg": b"..."}
```

```ts
import { getChunks } from "js-chunks";

const { chunks, images } = await getChunks("./deck.pptx", { listImages: true });
// images: { name: string; data: Uint8Array }[]  — name matches the ![](name) ref
```

```rust
use chunks_rs::formats::pptx;

// Returns (chunks, images); images are (name, bytes) pairs
let (chunks, images) = pptx::chunk_with_images("deck.pptx", "default", 3, 1, 3, 15)?;
```

Image extraction is supported for DOCX, PPTX, XLSX, HTML, PDF, DOC, PPT, EPUB,
IPYNB, EML, and ODT/ODP — see [Supported Formats](/docs/supported-formats).

## Next steps

- [Input Sources](/docs/input-sources) — paths, bytes, uploads, URLs
- [Chunking Modes](/docs/chunking-modes) — pick the right strategy
- [Streaming](/docs/streaming) — bounded-memory processing for large files
- [Framework Integration](/docs/framework-integration) — FastAPI, Express, Axum, and more
- [API Reference](/docs/api-reference) — full signatures per language
