@docling/docling-core

中文文档
2.106.0发布于 2026/11/06MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 8.4万

TypeScript definitions and functions for using Docling output.

原始使用文档
文档目录7 节
  1. Getting started
  2. Install package
  3. Convert and fetch
  4. Iterate and discriminate
  5. Read DocLang
  6. Read DCLX archives
  7. Limitations

Docling Core

TypeScript definitions and functions for using Docling output, which simplifies document processing, parsing diverse formats — including advanced PDF understanding. This package supports integrating Docling output into your Type-/JavaScript app with type definitions and utility functions that reflect the Docling Core Python library.

Getting started

Install package

npm i @docling/docling-core

Convert and fetch

To convert a document you can:

  • Use a separate document conversion service, such as docling-serve.
  • Integrate Docling into your own API, or use the Docling CLI for a quick web service.
  • Pre-convert documents and host these as static resources, on a COS bucket for example.

Next, fetch the (typed) conversion:

import { type DoclingDocument } from '@docling/docling-core';

async function fetchConversion(url: string) {
  const response = await fetch(url);

  return (await response.json()) as DoclingDocument;
}

Iterate and discriminate

Use the utility and typing functions for easy access to the converted document contents:

import { iterateDocumentItems, isDocling } from '@docling/docling-core';

for (const [item, level] of iterateDocumentItems(conversion)) {
  if (isDocling.TextItem(item)) {
    console.log(item.text);
  } else if (isDocling.TableItem(item)) {
    ...
  }
}

Read DocLang

@docling/docling-core/doclang turns DocLang XML into a DoclingDocument. It is a port of the Python DocLangDocDeserializer, and its JSON output matches Python's.

import { deserializeDocLang } from '@docling/docling-core/doclang';

const doc = deserializeDocLang(doclangXml); // browser: uses the native DOMParser

In Node, pass a DOMParser. @xmldom/xmldom is an optional peer dependency, so browser bundles never include it.

import { DOMParser } from '@xmldom/xmldom';

const doc = deserializeDocLang(doclangXml, { DOMParser });

The options mirror the Python deserialize_str keyword arguments:

  • pageNo: the page of content before the first <page_break/> (default 1).
  • maxXmlBytes, maxDepth, maxElements: budgets for untrusted input. Exceeding one throws.
  • repairUnescapedText: escape a bare &, a < that cannot start markup, a stray ]]> and illegal control characters before parsing. Off by default, so the input must be well-formed XML.
  • onWarning: receives warnings (default console.warn). <track> is not supported yet and is skipped, with all its content, with a warning.

Read DCLX archives

deserializeDclx reads a DCLX archive from bytes (Uint8Array, ArrayBuffer, Blob or File). Images are embedded in the document as base64 data URIs.

import { deserializeDclx } from '@docling/docling-core/doclang';

const doc = await deserializeDclx(await (await fetch(url)).arrayBuffer());

In Node, pass a DOMParser like with DocLang.

Limitations

This package does not

  • Convert documents directly from within a JavaScript runtime. It is not a port of Docling.
  • Support Docling output formats other than JSON and DocLang (read-only), such as Markdown.

版本与发布记录

@docling/docling-core 共发布 18 个版本,首次发布于 2025/01/25;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.106.0latest2026/11/067 天前
2.105.02026/11/0310 天前
2.104.02026/10/2519 天前
2.103.02026/10/2024 天前
2.102.02026/10/1925 天前
2.101.02026/10/081 个月前

关于 @docling/docling-core 的常见问题

@docling/docling-core 是什么?

TypeScript definitions and functions for using Docling output.

如何安装 @docling/docling-core?

在项目目录运行 npm install @docling/docling-core,或使用 pnpm add / yarn add / bun add。

@docling/docling-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@docling/docling-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@docling/docling-core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@docling/docling-core 可以商用吗?

@docling/docling-core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@docling/docling-core 的下载量有多少?

根据 npm 官方下载统计,@docling/docling-core 在 2026/10/13 – 2026/11/11 这 30 天内被下载 84,318 次,日均约 2,811 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@docling/docling-core 还在维护吗?

最新版本 2.106.0 发布于 2026/11/06(7 天前);至今共发布 18 个版本,其中过去 12 个月发布了 11 个;首次发布于 2025/01/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。