How to Install Unstructured for AI Document Processing (2026)

Quick answer

To set up Unstructured document processing, install the library with pip install "unstructured[all-docs]" on Python 3.9 or higher, then partition a file with the partition function in Python. The open-source library is free under the Apache 2.0 licence. In our worked example, processing 5,000 pages a month on your own machine avoids a $600-a-year hosted bill.

Your AI chatbot does not fail because the model is weak. It fails because someone fed it a contract with the headings stripped out, the tables flattened, and page two glued to page nine. Unstructured document processing fixes that first, unglamorous step: it turns messy files into typed elements your pipeline can actually trust.

Quick Answer

To set up Unstructured document processing, install the library with pip install "unstructured[all-docs]" on Python 3.9 or higher, then partition a file with the partition function in Python. The open-source library is free under the Apache 2.0 licence. In our worked example below, processing 5,000 pages a month on your own machine avoids a $600-a-year hosted bill.

In this article

  • How we checked this guide
  • What Unstructured replaces, and what it does not
  • How Unstructured document processing works
  • Routes: open-source library, Docker, or hosted platform
  • Requirements before you install Unstructured
  • Step 1: install Unstructured
  • Step 2: partition your first document
  • Step 3: pick the right strategy
  • Step 4: chunk the elements for RAG
  • Step 5: process more file types
  • Step 6: check titles, tables, and reading order
  • First-run security steps you must not skip
  • Backup and update routine
  • Common errors and fixes
  • Tips and tricks that save money
  • The real cost maths
  • When not to self-host Unstructured
  • Pros and cons
  • Our verdict
  • FAQ
  • Strategic Pivot
  • Sources

How we checked this guide

We verified every install command, strategy description, and licence fact on the official Unstructured GitHub repository and the official Unstructured documentation on December 3, 2026. Paid comparison prices come from the official Unstructured pricing page, checked the same day. Nothing here is copied from a roundup.

Where the official pages name a limit — a Python version floor, a system dependency, a per-page rate — we say so plainly. If a claim could not be verified on an official page, it stays out of this guide.

What Unstructured replaces, and what it does not

Unstructured replaces the paid per-page parsing step at the front of a document workflow. Many small businesses pay a hosted service for every page just to turn PDFs, Word files, web pages, and emails into clean text a chatbot or search tool can read. The open-source library does that partitioning on your own machine, without a per-page meter.

Unstructured official GitHub repository for unstructured document processing

It also replaces the fragile home-made chain of one extractor for PDFs, another for Word files, a scraper for HTML, and an OCR script for scans. One library ingests PDFs, HTML, Word documents, and many more file types, then returns a standard set of document elements with metadata that downstream tools can share.

What Unstructured does not replace is the rest of your AI stack. It does not embed text, store vectors, or answer questions. You still need an embedding model, a vector store, and a framework such as the one in our LlamaIndex RAG app guide or our Haystack RAG chatbot guide. If your problem is PDF conversion quality rather than multi-format ingestion, compare our Docling PDF to Markdown guide and our Marker PDF conversion guide before you commit.

Think of Unstructured as the sorting desk in a mail room. It opens every envelope, labels each piece, and puts it in the right tray. Your RAG framework still reads the mail and answers the customer.

Best for: owners and operators who feed mixed document types into AI tools every week and want one ingestion layer instead of five scripts. Skip if: you process a handful of files a year and have no one who can run a Python command — a hosted route will feel easier.

How Unstructured document processing works

A plain text extractor returns one long string. That string has lost the very structure your chatbot needs: which lines are headings, where a table starts, which paragraph belongs to which section. Unstructured instead partitions a document into typed elements — titles, narrative text, list items, tables, and other categories — each carrying metadata such as the source file and page information.

That typing is the whole point. A title can become a chunk boundary. A table can be kept whole instead of being sliced mid-row. Narrative text can be embedded while headers, footers, and boilerplate are filtered out. Cleaning and staging steps then format the elements for the next stage, whether that is a vector database, an agent, or a fine-tuning dataset.

The library routes each file to the right partition function. The general partition function detects the file type and calls the matching parser, while file-specific functions such as partition_pdf give you direct control when you already know what you are holding. Output can be inspected element by element or written to JSON with elements_to_json, which makes quality checks easy before anything reaches a customer.

One honest limit belongs here, not in a footnote. The vendor itself states that its hosted models produce higher-quality output than the open-source library, and it publishes benchmark comparisons to support that claim. Those are vendor-reported figures, not independent tests, so treat them as a reason to test on your own documents rather than as a verdict. For many small-business corpora the free library is good enough; for dense tables and degraded scans, your own test will tell you quickly.

Routes: open-source library, Docker, or hosted platform

Unstructured offers three practical routes. Choosing well matters more than any single setting.

RouteLicence / price anchorBest forSkip if
Open-source library (pip)$0 licence, Apache 2.0Developers who want partitioning inside their own Python pipelineNobody on the team can maintain a Python environment
Open-source library (Docker)$0 licence, Apache 2.0Teams who want the system dependencies packaged and reproducibleYou cannot run containers on your server
Hosted platformBalanced $0.010/page, Best $0.015/pageZero-maintenance processing with vendor models and supportPage volume makes per-page rates your biggest line item

The pip route is the default for a small pipeline: one package, explicit extras per file type, and full control over versions. The Docker route trades a little convenience for reproducibility, because the image carries the awkward system libraries that PDFs and Office files need. The hosted platform still wins on one axis: nobody maintains anything, and its newer models are the vendor’s highest-quality option.

Requirements before you install Unstructured

Unstructured needs Python 3.9 or higher. The official quickstart uses Python 3.12 as its example, which is a sensible target for a new project. A virtual environment manager is recommended so this library’s dependencies never collide with another project’s.

System dependencies are the requirement people miss. For maximum compatibility the documentation lists libmagic-dev for filetype detection, poppler-utils and tesseract-ocr for images and PDFs (plus tesseract-lang for additional language support), and libreoffice for Microsoft Office documents. You may not need all of them: a pipeline that only reads text files, HTML, XML, and email needs none of the heavy extras. Install for the file types you actually process, not for every type the library supports.

Decide two things before you write code. First, where originals and partitioned output will live, with originals kept read-only. Second, which strategy your hardest document needs, because strategy choice drives both quality and runtime more than any other setting. Finally, confirm the licence position for your use: the library is Apache 2.0, which permits commercial use, and the project states the open-source library is and will stay completely free.

Step 1: install Unstructured

Create a clean Python environment first. With pip, the base install covers plain text files, HTML, XML, JSON, and emails with no extra dependencies:

Unstructured official quickstart for unstructured document processing
pip install unstructured

To support all document types, install the full extra instead:

pip install "unstructured[all-docs]"

Most small businesses should install only the extras they need. A team processing PDFs and Word files, for example, installs exactly those two:

pip install "unstructured[pdf,docx]"

The available extras mirror the file types: csv, docx, epub, image, md, odt, org, pdf, pptx, rst, rtf, tsv, and xlsx, with all-docs covering the full list. The official quickstart uses the uv package manager instead of pip; the equivalent commands are uv add unstructured and uv add "unstructured[pdf]". Either tool works — pick the one your team already uses and stay consistent.

Then install the system dependencies for your file types. On a Linux server that means libmagic-dev for filetype detection, poppler-utils and tesseract-ocr for PDFs and images, and libreoffice for Office documents. The GitHub installation notes add that pandoc is bundled automatically through the pypandoc-binary Python package, so no separate pandoc install is needed.

If system dependencies are the part you dread, use the Docker route. Pull the official image and start a container:

docker pull downloads.unstructured.io/unstructured-io/unstructured:latest
docker run -dt --name unstructured downloads.unstructured.io/unstructured-io/unstructured:latest

Verify the install before you trust it. Open Python and import the partition function; if the import fails, fix the environment first, because every later step assumes the library is importable. Pin the version you tested in your requirements file, so a reinstall next quarter reproduces today’s behaviour instead of surprising you.

Step 2: partition your first document

Start with a document you know well — a price list, a policy, a short report — so you can judge the output against reality. The official quickstart pattern partitions a PDF and writes the elements to JSON:

from unstructured.partition.pdf import partition_pdf
from unstructured.staging.base import elements_to_json

elements = partition_pdf(filename="your-file.pdf")
elements_to_json(elements=elements, filename="your-file-output.json")

Open the JSON and read it like a customer would. Titles should be typed as titles, paragraphs should read in order, and tables should still look like tables. This five-minute read is your quality gate; never pipe uninspected elements into a chatbot.

When you do not know the file type in advance, use the general partition function, which detects the type and routes the file to the matching parser:

from unstructured.partition.auto import partition

elements = partition(filename="your-file.pdf")
print("\n\n".join([str(el) for el in elements]))

One honest limit: partitioning understands structure, not truth. If the source document contains a wrong price, the elements will faithfully contain the wrong price. Parsing quality and content quality are separate checks, and your business owns the second one.

Step 3: pick the right strategy

Strategy selection is a quality decision first and a speed decision second. For PDFs and images, the official documentation describes four strategies. The auto strategy chooses based on document characteristics and is the default. The fast strategy is rule-based, using traditional extraction techniques to pull text quickly; the documentation notes it is not recommended for image-based files. The hi_res strategy is model-based: it identifies the layout of the document, which improves element classification where correctness matters. The ocr_only strategy uses optical character recognition to extract text from image-based files.

Unstructured official partitioning strategies for unstructured document processing

The practical rule is simple. Start with fast on clean digital PDFs, because it is dramatically quicker than model-based routes. Move to hi_res when tables come out garbled, columns interleave, or element types look wrong. Use ocr_only for pure scans with no text layer. Leave auto in place only until you know your corpus well enough to choose deliberately.

Test strategies on your hardest document, not your easiest. Partition the same five pages with fast and hi_res, compare the element types and table output, and let your own documents decide. If the outputs match, the cheaper strategy wins — and on the hosted platform, strategy choice is also a pricing decision, as the cost maths below shows.

Language matters for OCR. If your scans are not in English, install the matching tesseract-lang support and pass the correct languages to the partition call. OCR with the wrong language pack returns confident garbage without erroring, which is the worst kind of failure.

Step 4: chunk the elements for RAG

Partitioning gives you elements; chunking turns elements into the passages your retriever will search. Keep the two steps separate, because inspecting element counts first tells you whether the parse itself succeeded. If titles are missing or tables are typed as narrative text, no chunk setting will rescue the output.

The common pattern is chunking by title: elements are grouped under their nearest heading, so a passage keeps the section context a customer question usually needs. The hosted API exposes chunking strategies named basic, by_title, by_page, and by_similarity, with controls such as max_characters and overlap; the open-source library offers the same by-title idea in Python. Whichever route you take, apply three handling rules. Keep titles as chunk boundaries and never split them. Keep each table as its own chunk so its grid structure survives. Keep list items with their parent heading instead of orphaning them.

Prepend light metadata — source file, section title, page — to each chunk before embedding. That small habit is what lets your chatbot cite a document instead of merely sounding confident. From there, chunks flow into the frameworks in our LlamaIndex RAG app guide and Haystack RAG chatbot guide.

Step 5: process more file types

The same element model covers the rest of a small business’s files. Word documents, PowerPoint decks, spreadsheets, HTML pages, emails, CSV files, and images each have a partition function, and the general partition call routes them automatically once the matching extra is installed. That uniformity is the library’s real advantage: downstream code handles one element format instead of seven parsers’ quirks.

Add file types one at a time. Install the extra, partition one known file of that type, inspect the elements, and only then add the type to your batch job. Office documents deserve special care because they depend on LibreOffice being present; a missing system dependency surfaces as a failed partition, not as a helpful warning at install time.

For batch work, keep the discipline boring: originals read-only in one folder, partitioned JSON in another, one file processed at a time with failures logged rather than silently skipped. A folder of supplier PDFs, contracts, and web exports becomes a folder of element files in one run, ready for chunking and embedding.

Step 6: check titles, tables, and reading order

Before any partitioned file reaches customers, run three checks. First, titles: confirm the heading hierarchy matches the document’s real structure, because your chunker and your chatbot both navigate by it. Second, tables: confirm row counts match the source and no column has drifted into its neighbour. Third, reading order: pick a two-column page and confirm the elements read down one column, then the other, instead of zig-zagging across both.

Numbers deserve their own check. Prices, quantities, dates, and phone numbers are where a parsing error becomes a business error. Spot-check every figure type against the source document, especially in tables with merged cells or footnote markers.

Build a small golden set: five documents you have verified by hand, covering a clean PDF, a scanned page, a dense table, a Word file, and an HTML export. Re-run the golden set after every library upgrade and every strategy change. If the output changes, you learn it from your test, not from a customer complaint. Keep the element JSON for audited documents, since its metadata lets you point to the exact source a chatbot answer came from.

First-run security steps you must not skip

Local execution is the library’s security headline: documents partition on your machine, with no account and no upload. That advantage only holds if you treat the processing machine like part of your records system, because it now holds copies of everything you parse.

Keep source documents and partitioned output under the same access rules as the originals. A JSON export of a client contract is still a client contract. Folder permissions, encrypted disks, and a short list of who can read the output directory are the control that makes local processing safer than an upload.

If you expose partitioning through an API server for a team, keep it inside your network boundary and require authentication. A document-processing endpoint accepts file uploads by design, which makes an open one an invitation for strangers to burn your compute and probe your parser with hostile files. Treat uploaded files as untrusted input: process them in an isolated environment, limit file sizes, and never let a parser write outside its output folder.

The licence check is a compliance step, not paperwork. The library is Apache 2.0, free including commercially, and the project states it will stay completely free. The hosted platform is a separate commercial product with its own terms; if you move sensitive documents there, review its security claims and deployment options on the official pages before you upload, not after.

Finally, watch what leaves the machine downstream. Partitioning locally keeps documents home, but the moment you send chunks to a cloud embedding or language-model service, that content travels. For sensitive files, either keep the whole pipeline local or make the external step a deliberate, documented decision.

Backup and update routine

Your backup unit is not the JSON alone. Keep three things: the original documents, the partitioned output, and the exact environment that produced it — the pinned library version, your strategy choice, and your processing script. With those three, any output can be regenerated; without the originals, nothing can.

Store originals read-only and back them up on the same schedule as your other business records. Partitioned output can be regenerated, so it needs a lighter touch — but regeneration costs compute time, so keeping the output is still cheaper than rebuilding a large archive.

Update deliberately. The library releases frequently, and element classification can shift between versions. Upgrade in a test environment, re-run your golden set, compare the elements, and only then promote the new version. A pinned version plus a golden set turns an upgrade from a gamble into a five-minute check.

Common errors and fixes

Most failures fall into a short list. A missing-extra error when partitioning a Word or PDF file means the matching extra was never installed; install it explicitly, for example pip install "unstructured[pdf,docx]", rather than assuming the base package covers every type. A filetype-detection failure usually means libmagic-dev is absent; install the system dependency, not another Python package. PDF and image failures on a fresh server usually trace back to missing poppler-utils or tesseract-ocr; install both, plus tesseract-lang for non-English scans.

Garbled tables under the fast strategy are not a bug to report but a strategy to change: re-run the same file with hi_res and compare. Scanned pages returning empty text mean the file has no text layer; use ocr_only or hi_res so OCR actually runs. OCR output that looks like alphabet soup in a non-English document means the language pack or the languages argument is wrong; fix both together.

Slow first runs are normal when model-based strategies download what they need; judge runtime from the second run, not the first. And when a batch job fails halfway, the fix is process, not code: log the failing file, continue with the rest, and review the failures as a list instead of letting one corrupt PDF stop the night’s work.

Tips and tricks that save money

Install only the extras you need. A lean environment installs faster, breaks less, and is easier to audit than all-docs on a server that only ever sees PDFs. Start every new document type on the fast strategy and escalate only when your golden set proves hi_res earns its runtime; strategy discipline is the cheapest performance tuning you will ever do.

Filter elements before chunking. Headers, footers, page numbers, and boilerplate add noise to every embedding they touch, and removing them costs nothing. Keep tables whole and store their structured form alongside the text you embed, so retrieval can return a grid instead of a paragraph about a grid.

Cache partitioned output by file hash. Supplier price lists and policy documents change rarely; re-partitioning unchanged files burns compute for identical JSON. And if you use the hosted platform for overflow work, route clean digital PDFs to the cheapest adequate strategy — the rate card below shows how wide that gap is.

The real cost maths

Here is the comparison with real numbers, checked on the official pricing page on December 3, 2026. The open-source library costs $0 in licence fees; you supply the machine and the maintenance. The hosted platform charges per page from a prepaid balance: Balanced, the default strategy, is $0.010 per page, and Best, for the hardest layouts and densest tables, is $0.015 per page. Legacy strategies remain on the rate card: Fast at $0.002 per page, Hi-Res at $0.020 per page, and VLM at $0.030 per page. Audio is $0.015 per minute and video is $0.045 per minute, with video that has sound drawing the audio line too, for $0.060 a minute. Prices are in USD.

Unstructured official pricing page compared with unstructured document processing

Now the worked example. A small business processing 5,000 pages a month — supplier catalogues, contracts, manuals, and web exports — pays 5,000 × $0.010 = $50 a month on the Balanced strategy. That is $600 a year, every year, growing with volume. The same workload on the open-source library costs $0 in licence fees on a machine the business already owns. The saving in this scenario is $600 a year, before counting your maintenance time honestly against it.

Strategy choice swings the hosted bill hard. The same 5,000 pages cost $10 a month on the legacy Fast rate, $75 a month on Best, and $150 a month on VLM. That spread is the real lesson: hosted pricing rewards routing each document to the cheapest adequate strategy, while self-hosting removes the meter entirely and replaces it with a fixed, predictable maintenance habit. At low volume the hosted bill is small enough that convenience wins; at steady volume the licence-free route pulls ahead and keeps pulling.

When not to self-host Unstructured

Do not self-host when nobody will own it. A partitioning pipeline that breaks silently is worse than a hosted bill, because bad elements poison every answer downstream. If your team has no Python capacity and no plan to get any, the hosted platform’s maintenance-free route is the honest choice.

Do not self-host when volume is tiny. A few hundred pages a month costs a few dollars hosted; your setup time is worth more than the saving. And do not self-host when your hardest documents — degraded scans, dense financial tables — fail your golden set on the open-source strategies but pass on the vendor’s hosted models. Quality you cannot reach locally is a legitimate reason to pay per page.

Self-host when volume is steady, documents are sensitive, or the pipeline must run offline. Those three conditions are where $0 licence fees and local control stop being a preference and start being the correct engineering answer.

Pros and cons

Pros: free under Apache 2.0 with $0 per-page fees; one element format across PDFs, Office files, HTML, email, and images; typed elements with metadata that make chunking and citation practical; strategy choice from fast rule-based extraction to model-based layout detection; runs locally with no account or upload; Docker route packages the system dependencies.

Cons: you maintain the Python environment and system dependencies yourself; model-based strategies are slower and need a first-run download; the vendor’s hosted models claim higher output quality than the open-source library; OCR quality depends on installing the right language support; no vendor support desk or uptime guarantee on the open-source route.

Our verdict

Install Unstructured when documents arrive in mixed formats and feed AI tools every week. For steady volume the maths is not close: $0 in licence fees against a per-page bill that grows forever. Start with the extras you need, prove quality on a golden set, and keep the hosted platform as overflow for the documents your local strategies cannot handle.

Choose the hosted platform when volume is low, maintenance capacity is zero, or your hardest documents need the vendor’s models. The right answer is the one your own five test documents support — run them before you commit either way.

FAQ

Is Unstructured free for commercial use?

Yes. The open-source library is licensed under Apache 2.0, which permits commercial use, and the project states the library is and will stay completely free. The hosted platform is a separate paid product priced per page.

Does Unstructured work offline?

Yes. The library partitions documents on your own machine with no account and no upload. Model-based strategies may download model files on first use, so run your first partition while connected, then process offline.

Can Unstructured handle scanned PDFs?

Yes. Use the ocr_only strategy for pure scans, or hi_res when layout and element classification also matter. Install tesseract-ocr and the matching language support first, and test on your worst scan before trusting archive-wide output.

How does Unstructured compare with the hosted platform on cost?

Self-hosting charges $0 per page in licence fees. The hosted platform charges $0.010 per page on the Balanced strategy and $0.015 per page on Best, drawn from a prepaid balance. At 5,000 pages a month, Balanced costs $600 a year that self-hosting avoids.

What should I use Unstructured output with?

Feed the elements into a chunking step, then embed the chunks for retrieval. Chunk by title so passages keep their section context, keep tables whole, and store source metadata with each chunk. Our LlamaIndex and Haystack guides cover the next step.

Strategic Pivot

Unstructured removes the per-page parsing meter, but your full AI stack still has embedding, model, and hosting lines to budget. Before you commit to a route, run your own page volume through our AI Cost Calculator and compare the hosted bill against the self-hosted habit with your real numbers, not ours.

Sources

  • Unstructured GitHub repository (Unstructured-IO/unstructured) — licence, install commands, Docker route, and system dependencies, checked December 3, 2026.
  • Unstructured documentation, open-source quickstart — Python requirement, extras, and the partition-to-JSON pattern, checked December 3, 2026.
  • Unstructured documentation, partitioning strategies — auto, fast, hi_res, and ocr_only descriptions, checked December 3, 2026.
  • Unstructured pricing page — Balanced, Best, legacy strategy, audio, and video rates, checked December 3, 2026.

Price note — updated December 3, 2026: Prices in this post were checked on December 3, 2026. When you are reading this, the price may be lower or higher — always check the official pricing page before you buy.

Pros

  • Free under Apache 2.0 with $0 per-page fees
  • one element format across PDFs, Office files, HTML, email, and images
  • typed elements with metadata that make chunking and citation practical
  • strategy choice from fast rule-based extraction to model-based layout detection
  • runs locally with no account or upload
  • Docker route packages the system dependencies

Cons

  • You maintain the Python environment and system dependencies yourself
  • model-based strategies are slower and need a first-run download
  • the vendor's hosted models claim higher output quality than the open-source library
  • OCR quality depends on installing the right language support
  • no vendor support desk or uptime guarantee on the open-source route
Our verdict

Install Unstructured when documents arrive in mixed formats and feed AI tools every week. For steady volume the maths is not close: $0 in licence fees against a per-page bill that grows forever. Choose the hosted platform when volume is low, maintenance capacity is zero, or your hardest documents need the vendor's models.

Leave a Comment