DEV.co
AI Frameworks · explosion

spacy-layout

spacy-layout is a Python plugin that converts PDFs, Word documents, and similar files into structured, analyzable text using spaCy's NLP capabilities. It extracts document layout (sections, headings, tables), converts tables to pandas DataFrames, and creates spaCy Doc objects for downstream NLP tasks like entity recognition or RAG chunking.

Source: GitHub — github.com/explosion/spacy-layout
908
GitHub stars
64
Forks
Python
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryexplosion/spacy-layout
Ownerexplosion
Primary languagePython
LicenseMIT — OSI-approved
Stars908
Forks64
Open issues26
Latest releaseUnknown
Last updated2026-03-27
Sourcehttps://github.com/explosion/spacy-layout

What spacy-layout is

spacy-layout wraps Docling's document conversion engine within spaCy's pipeline architecture, tokenizing extracted content and exposing layout metadata via custom extension attributes (Doc._.layout, Span._.layout). It preserves bounding box coordinates, page information, and tabular data structures, enabling both linguistic analysis and layout-aware document processing.

Quickstart

Get the spacy-layout source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/explosion/spacy-layout.gitcd spacy-layout# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

RAG pipeline document preparation

Convert PDFs to clean, chunked text with semantic structure (sections, headings) preserved, enabling intelligent retrieval and generation from document corpora.

Document intelligence and extraction

Extract named entities, classify content by section type, and link text spans to document layout features for downstream analytics or knowledge graph construction.

Multi-format document normalization

Standardize processing of heterogeneous input formats (PDF, DOCX, etc.) into consistent spaCy Doc objects with uniform layout annotation and tabular data extraction.

Implementation considerations

  • Requires Python 3.10+; verify environment constraints and dependency compatibility with existing spaCy versions.
  • Depends on Docling for document conversion; evaluate Docling's performance and format support for your document corpus before adoption.
  • Extension attributes (Doc._.layout, Span._.layout) must be re-initialized on deserialization from binary .spacy files; plan serialization workflows accordingly.
  • Table extraction yields pandas DataFrames; ensure pandas is in your stack or account for additional dependency footprint.
  • No official release versioning yet (latestRelease: n/a); monitor GitHub for breaking changes and pin dependency versions explicitly.

When to avoid it — and what to weigh

  • Requires pixel-perfect OCR or handwriting recognition — spacy-layout relies on Docling's underlying extraction; scanned or image-based documents with no embedded text require separate OCR preprocessing.
  • Low-latency, high-throughput inference needed — Document conversion is resource-intensive; not suitable for real-time single-document processing at scale without horizontal scaling or caching strategies.
  • Complex proprietary document formats — If you must support custom binary or niche document formats beyond PDF/DOCX, verify Docling's format coverage or prepare custom preprocessing.
  • Non-Python workflows — Python 3.10+ is mandatory; integration into non-Python backends requires API wrapping or separate microservice architecture.

License & commercial use

MIT License (OSI-approved permissive license). Permits commercial use, modification, and distribution with attribution; no warranty provided.

MIT License explicitly permits commercial use without royalty or licensing fees. No restrictions on proprietary applications. However, verify Docling's license (dependency) for your use case, as it may have different terms.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

Processes untrusted PDFs and documents; malformed files could trigger parsing errors or memory issues. Validate and sandbox input documents if processing user-supplied content. Dependency on Docling means security posture depends on that library's maintenance. No security audit or vulnerability disclosure process mentioned. Review both projects' security practices before handling sensitive documents.

Alternatives to consider

LlamaIndex with document loaders (pdf, docx)

Language-agnostic document parsing and chunking for RAG; integrates with multiple LLM backends but lacks spaCy-native layout annotation and lower-level linguistic control.

Unstructured.io (document parsing library)

Format-agnostic structured extraction with metadata; lighter weight than spacy-layout but no native spaCy integration and less NLP-specific feature exposure.

PyPDF2 + pdfplumber + spaCy (manual integration)

Fine-grained control and lighter dependencies; requires custom glue code for layout annotation and table extraction but avoids Docling dependency.

Software development agency

Build on spacy-layout with DEV.co software developers

spacy-layout brings production-ready document conversion to spaCy workflows. Contact Devco to integrate structured document intelligence into your RAG, knowledge extraction, or AI application stack.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

spacy-layout FAQ

Does spacy-layout require OCR for scanned PDFs?
No; it relies on embedded text. Scanned PDFs require separate OCR preprocessing. Verify your document corpus contains extractable text before adoption.
Can I use spacy-layout with transformer models like en_core_web_trf?
Yes. spacy-layout outputs standard spaCy Doc objects. You can pipe them through any spaCy model for POS tagging, NER, dependency parsing, etc.
What formats does spacy-layout support?
It wraps Docling, which supports PDF, DOCX, and others. Check Docling's documentation for the full list and limitations.
Is there a performance penalty for serialization and deserialization?
Not significant, but you must reinitialize spaCyLayout to repopulate custom extension attributes. Plan your serialization strategy accordingly to avoid re-processing.

Software developers & web developers for hire

Adopting spacy-layout is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate ai frameworks software in production.

Ready to streamline document processing in your NLP pipeline?

spacy-layout brings production-ready document conversion to spaCy workflows. Contact Devco to integrate structured document intelligence into your RAG, knowledge extraction, or AI application stack.