Meet the Docling team at IBM TechXchange 2026 · Atlanta, GA · October 26–29, 2026See our sessions
DoclingDocling for IBM watsonx
Guides

Explore with DocLang

Get the full document structure as DocLang, inspect it visually and query sections, tables and cells

Markdown is great to read, but it loses structure. A table becomes pipes and dashes, and you can no longer tell which page a paragraph came from. DocLang keeps everything: typed elements, nested sections, table cells, captions, reading order and page positions. See Concepts for an introduction.

This guide shows how to get DocLang from the service, look at it, and pull out exactly the part you need, from the terminal or from an AI agent.

1. Request DocLang output

Add doclang (the XML document) or dclx (an archive with the document and its images) to to_formats:

curl -X POST "${DOCLING_SERVICE_URL}/v1/convert/source/async" \
  -H "X-Api-Key: ${DOCLING_SERVICE_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "sources": [{ "kind": "http", "url": "https://arxiv.org/pdf/2206.01062" }],
    "options": { "to_formats": ["md", "dclx"] }
  }'

Poll the task and download the .dclx artifact from the result, as described in Basic Conversion. In the Workbench, tick DCLX under output formats when you create a task.

2. Look at it in the DocLang Viewer

Open the DocLang Viewer and drop the .dclx file onto it. It runs in your browser and shows three synchronized panes:

  • the original page, with every detected element outlined
  • the DocLang tree
  • a reading view

DocLang Viewer showing a converted page, its DocLang tree and the reading view, with a table cell highlighted in all three panes

Click any element to see where it is on the page and in the tree. This is the quickest way to check how a difficult page, such as a complex table, was understood.

3. Query it with dclq

dclq is a small command-line tool for DocLang files. Think of it as jq for documents.

pip install dclq
dclq inspect paper.dclx                              # inventory: pages, sections, tables, pictures
dclq outline paper.dclx                              # heading tree, with the path to each section
dclq grep -i 'annotation' paper.dclx                 # find matching elements
dclq show    paper.dclx '/heading[2]' --section      # print one whole section
dclq list    paper.dclx --type table_cell --page 1   # list elements of one type on a page

Every element has a path, such as /heading[2]. Use the paths printed by outline to address a section precisely, for example to cite it or to feed only that section to an LLM.

4. Use DocLang with AI agents

DocLang works well with agents. Instead of pasting a 50-page document into a prompt, an agent can:

  1. read the outline,
  2. pick the relevant section,
  3. fetch only that section with dclq show.

This uses fewer tokens and makes it easy to see where an answer came from. The Agent Skills page uses this pattern.

Working in Python

If you use the Python SDK, the converted document can be saved as DocLang directly:

from docling.service_client import DoclingServiceClient
import os

with DoclingServiceClient(
    url=os.environ["DOCLING_SERVICE_URL"],
    api_key=os.environ["DOCLING_SERVICE_API_KEY"],
) as client:
    result = client.convert(source="https://arxiv.org/pdf/2206.01062")
    result.document.save_as_doclang_archive("paper.dclx")  # or save_as_doclang("paper.xml")

The Docling documentation describes the Python document model in detail.

On this page