Convert from PDF

PDF to XML

Extract text, fonts, coordinates, and layout parameters from your PDF files into a structured XML file. Perfect for programmatic parsing.

  • Free forever, no signup
  • Runs in your browser — private by design
  • Works on every device and browser

What is the PDF to XML Extractor?

PDFs are designed for presentation, not for data processing. They describe where characters should be placed on a page, but they lack semantic structure. There is no concept of a "paragraph," a "table," or a "heading" in raw PDF data, making it incredibly difficult to write programs that extract data from them.

Our PDF to XML converter solves this challenge. It parses the PDF's internal layout using PyMuPDF and extracts page boundaries, text blocks, lines, character spans, fonts, sizes, colors, and coordinates, mapping them into a clean, structured XML tree. This turns unstructured document layouts into structured, machine-readable XML data.

Why Convert PDF to XML?

Convert your PDFs to XML when you need:

  • Programmatic Data Extraction: Reconstruct documents programmatically in languages like Python, Node.js, or Java by parsing structured XML tags and bounding boxes.
  • Detailed Layout Analysis: Extract the exact coordinates (x, y, width, height) of text blocks, lines, and images to analyze document structures or train machine learning models.
  • Database Ingestion: Import text content along with font hierarchies and positioning data directly into relational databases or search indexes.

Key Features

  • Detailed Node Extraction: Outputs nested tags representing pages, text blocks, lines, images, and character spans.
  • Coordinate Mapping: Every structural tag contains a bbox attribute defining its precise bounding box on the page.
  • Font and Color Preservation: Spans include metadata for the font name, size, and text color, allowing you to differentiate headings from body text.
  • Fast and Secure Backend: Process multi-page documents quickly. All files are encrypted and automatically deleted after processing.

Real-World Use Cases

Automated Invoice Parsing

A logistics company receives thousands of shipping invoices as PDFs. To automate billing, they convert the PDFs to XML, allowing their parsing scripts to locate and extract invoice numbers, dates, and line items based on their coordinate bounding boxes.

Academic Text Mining

Researchers want to extract section titles and paragraphs from a library of academic PDF papers. They convert the PDFs to XML, allowing their scripts to identify headers by filtering tags with larger font sizes and bold attributes.

Document Migration and Archiving

An enterprise migrates historical records from static PDFs to a structured XML CMS. They use the tool to extract the raw text content alongside its page layout structure, preserving the reading order of the document.

Best Practices for Extraction

  1. OCR Preprocessing: If you upload a scanned PDF that is just an image, the XML output will contain image tags but no text spans. Run our OCR PDF tool first to generate a text layer before extracting XML.
  2. Handle Bounding Box Coordinates: Bounding boxes (bbox) are expressed in standard PDF points (72 points per inch) originating from the top-left of the page. Use these coordinates to group lines or detect columns in your code.

Frequently Asked Questions

What does the output XML look like? The output is a structured XML tree with a root <document> tag. It contains <page> tags (with width and height attributes), which contain <block> tags (representing paragraphs), <line> tags, and <span tags (with text content, font, size, and color attributes).

Can this tool extract images? The tool detects image blocks and includes their positions and dimensions as <image> tags in the XML, but it does not extract the raw image files themselves.

Will it extract tables? Yes. The text inside tables will be extracted within block, line, and span tags along with their positioning coordinates, allowing you to reconstruct the table grid programmatically.

Is there a page limit? We support PDF documents up to 100MB, accommodating documents with hundreds of pages.

Are my files kept private? Yes. All file transfers are secured via HTTPS. Documents are processed ephemerally on our secure servers and permanently deleted shortly after conversion. We do not inspect or share your files.

Why use Pdfly's PDF to XML?

Built with the same craft as a native app — in a browser tab.

Detailed Structure Extraction

Extracts font sizes, coordinates, text blocks, and page boundaries into a clean XML tree.

Programmatic Integrations

Output is fully structured XML, ideal for processing in Python, Node.js, or importing into databases.

Page-by-Page Nodes

Segments the document tree by page, block, and line nodes to preserve layout information.

Secure & Encrypted

Files are handled over secure connections and deleted automatically after processing.

How to pdf to xml in 3 steps

Simple, fast, and totally free.

  1. 1Step 1

    Upload PDF

    Select the PDF file you want to extract XML from.

  2. 2Step 2

    Choose Extraction Level

    Select extraction parameters or stick to the default structured parsing.

  3. 3Step 3

    Save XML File

    Download the converted `.xml` file containing the extracted data.

Who uses PDF to XML?

Practical applications for this tool.

Data Ingestion

Extract invoice or report data from PDFs into XML files to load into automated ERP databases.

Text Mining

Analyze the layout and structural syntax of documents for academic research or NLP preprocessing.

PDF to XML — FAQ

Answers to the questions people ask most about PDF to XML.

Related PDF tools

Great pairings with PDF to XML.