PDF to XML extracts the text layer from a PDF and rebuilds it as structured XML. Load a text-based PDF, choose one of four schemas (Document, TEI-like, Flat, Minimal), set page ranges and toggles, then copy or download the .xml. It works on digital PDFs — not scanned images, which need OCR first. Everything runs in your browser, so your document never leaves your device.
What is a PDF to XML converter?
A PDF to XML converter reads the text layer inside a PDF and rebuilds it as structured XML. PDFs fix every character at a precise position; XML represents the document's structure — pages, headings, paragraphs, metadata. The converter's job is to read the words, reconstruct reading order, group lines into paragraphs, spot heading-like lines, and package everything in one of four schemas that a downstream parser can consume.
Under the hood, this tool uses pdf.js to decode the PDF and read its metadata, then builds the XML string in JavaScript. Everything runs in your browser, so the file never leaves your device.
What does the XML look like?
The default Document schema wraps everything in <document>, adds a <metadata> block (title, source, pages, generated timestamp, PDF title/author/producer), then a <body> containing one <page> per PDF page. Inside each page, headings become <heading> and everything else becomes <paragraph>. Every text node is XML-escaped and control characters are stripped.
Who should use a PDF to XML converter?
Anyone feeding PDF content into a structured pipeline: content migration into a CMS, archival into a TEI repository, indexing into a search engine, training an NLP model, generating feeds, or converting into another structured format. If you just need plain text, use PDF to Text. If you need JSON, use PDF to JSON.
Why convert PDF to XML instead of copying text?
You can copy text from a PDF in a viewer, but the result is unstructured — no page boundaries, no headings, no metadata, and often broken line breaks. Structured XML gives a downstream parser everything it needs in one file.
Structure that parsers can read
The Document schema separates <heading> from <paragraph>, groups elements by <page>, and puts source metadata at the top. A migration script can walk the tree and rebuild content exactly as needed, without re-parsing the raw text.
Metadata the PDF carried
pdf.js exposes title, author, subject, keywords, creator and producer from the PDF's information dictionary. With Include PDF metadata on, all of those land in the XML as named elements, ready for archival or indexing.
Four schemas, one engine
Choose the schema that matches your consumer. The conversion algorithm (extraction, grouping, heading detection) is the same; only the tag structure differs. Try a small page range in each schema and keep the one that fits your pipeline.
How to convert a PDF to XML in 5 steps
The conversion is short and needs no account. Follow these steps and the first .xml will be ready in under a minute.
- Add your PDFDrag a text-based PDF onto the upload card, click Browse, or import from Google Drive or Dropbox. The file is opened in your browser with pdf.js — nothing is uploaded to a server.
- Choose an XML schemaDocument schema for general use, TEI-like for academic archives, Flat for simple consumers, Minimal for text-only pipelines. The schema decides the tag structure of the output.
- Pick pages and optionsConvert all pages, only the first, or a custom range. Toggle heading detection, paragraph grouping, page markers, metadata and pretty-print. All the sensible defaults are on.
- Preview the XMLSwitch between Preview (formatted with headings and page markers) and XML Source (syntax-highlighted, with truncation for very large outputs). The source updates live as you change settings.
- Convert and downloadClick Convert to XML. The tool extracts each page, groups lines into paragraphs, detects headings, builds the selected schema, and lets you download the .xml or copy it straight to your clipboard.
Test with page 1 first
On long PDFs, choose First page only and inspect the XML Source tab. If the output looks right, switch to All pages and run again. This is faster than re-extracting after discovering a schema mismatch.
Pasting the XML elsewhere
After conversion, the Copy button on the result panel puts the whole XML on your clipboard. Paste it into an editor, a curl request body, an API test tool, or a chat. The output is UTF-8 and well-formed, so it parses without cleanup.
The four XML schemas explained
Each schema produces a different tag structure from the same extracted content. Pick the one that matches what your consumer expects.
Document schema
<document> → <metadata> → <body> → <page> → <heading>/<paragraph>. The general-purpose default; human-readable and easy to migrate.
TEI-like schema
<TEI> → <teiHeader> + <text> → <body> → <div type="page"> → <head>/<p>. Academic archives and digital humanities pipelines.
Flat schema
<root> → <heading page="N">/<paragraph page="N">. Every element a direct child of the root; easy to iterate in XSLT or a simple reader.
Minimal schema
<text> → <line>. Text-only, one element per paragraph. Best when structure is not needed and the consumer just needs the words.
Honest limit: headings are detected heuristically by line height, and paragraphs are grouped by vertical gap. Multi-column layouts, footnotes and complex tables are flattened into a reading-order sequence. If the output looks wrong, try a different schema or toggle heading detection off — the extraction itself is unchanged.
The XML settings explained
Each setting changes the shape of the output. The defaults are safe for most PDFs.
Document title
Pre-fills from the filename. Written into the <title> metadata element (Document schema) or <title> in the TEI header. Leave blank to omit.
XML structure
Document, TEI-like, Flat or Minimal. Changing the schema re-renders the source preview immediately, so you can compare outputs before committing.
Page range
All pages, only the first, or a custom range with From and To. Skipping pages shortens conversion and keeps the XML focused.
Detect headings
Tall lines become <heading> (or <head> in TEI). Turn off if a page full of large body text produces false headings.
Group lines
Merges lines that share a paragraph. Turn off to keep every PDF line as its own element, matching the source layout more closely.
Include page markers
Keeps page boundaries visible in the output. Turn off for a single continuous document without page tags.
Include metadata
Adds PDF title, author, subject, keywords, creator and producer to the metadata block. Off for a lean XML without a <metadata> section.
Pretty-print
On adds indentation and newlines for human readers. Off minifies by collapsing whitespace between tags — smaller files for machine consumers. Both are valid XML.
Copy or download
Download saves a .xml file. Copy puts the entire XML on your clipboard, ready to paste into an editor, a request body or a chat.
Features of the PDF to XML converter
The tool was built for people who need structured output without building a pipeline.
Four schemas
Document, TEI-like, Flat and Minimal — each with its own tag structure. One extraction engine, four consumers.
Heading detection
Lines noticeably taller than the page's median line height become heading elements. This catches most section titles and lets a downstream consumer style them differently.
Paragraph grouping
Lines that share a paragraph are merged into one element. Large vertical gaps between lines trigger a paragraph break, so sections and lists stay separated in the XML.
PDF metadata extraction
When the PDF carries title, author, subject, keywords, creator or producer in its information dictionary, all six are written into the XML metadata block.
Pretty-print or minify
Toggle between indented, human-readable XML and minified XML with whitespace collapsed between tags. Both parse identically.
Live XML source preview
The XML Source tab shows the actual XML that will be downloaded, with syntax highlighting for tags, attributes and values. Updates live as you change settings.
One-click copy
After conversion, the Copy button puts the entire XML on your clipboard. No download, no file manager, no open-and-save dance.
Private, local processing
Everything runs in your browser. The PDF is read with pdf.js, the XML is built in JavaScript, and the file is created locally. Nothing is uploaded, logged or stored.
Text-based vs scanned PDFs
This is the most important thing to understand about PDF to XML conversion. Only one type of PDF works.
Text-based PDFs
Created by Word, Google Docs, LaTeX, online invoices, LibreOffice and most digital reports. They contain a real text layer that can be selected, copied and extracted. These convert well, and every setting works as intended.
Scanned PDFs
Created by a scanner or a phone camera. Each page is a picture with no text layer. Selecting text does nothing. These need OCR before they can be converted.
Quick test
Open the PDF and try to select a sentence with your mouse. If the text highlights, it has a text layer and this tool will read it. If nothing highlights, it is scanned and will need OCR first.
PDF to XML vs other extraction methods
Several tools can pull structured data out of a PDF. This table compares the common ones so you can pick the right tool for the task.
| Method | Runs in browser | Output structure | Handles scanned PDFs | Best for |
|---|---|---|---|---|
| This tool | Yes | XML (4 schemas) | No (needs OCR) | Text-based PDFs, migration, archival, private documents |
| Copy-paste into editor | Yes | Plain text | No | One or two pages, quick read |
| pdftotext + custom script | No | Custom | No | Batch pipelines, heavy automation |
| Adobe Acrobat Pro export | No | HTML / Office / XML | Yes (built-in OCR) | Scanned PDFs, layout-critical documents |
| Online paid services | Yes | Varies | Sometimes | Scanned PDFs, heavy documents |
Rule of thumb: if the PDF is text-based and you care about privacy, this tool is the fastest path to structured XML. If it is scanned, use an OCR pass first — no browser tool can reconstruct a picture as structured text.
Your PDF stays private
Everything happens in your browser. The PDF is loaded with pdf.js, the text is extracted page by page, and the XML string is built locally. Nothing is uploaded, logged or stored. When you close the tab, the file is gone from memory.
Local processing
Conversion runs on your device, so confidential documents never leave your computer or phone. There is no server, no log, no retention window — which is why the tool is safe for legal, medical and financial documents.
Direct cloud downloads
When you import from Google Drive or Dropbox, your browser fetches the file straight from that provider after you grant access. The file is processed locally, not routed through any server of ours.
No account needed
You can convert without signing in. Read our privacy policy for details about the site itself.
Tips for cleaner XML output
- Try Document schema first. It is the most general and easiest to read. Switch to TEI only if your consumer expects TEI.
- Use Flat for XSLT transformations. No nesting means simpler stylesheets and faster iteration.
- Turn on minify for storage. If you are saving many XML files, unchecking Pretty-print can cut file size significantly.
- Include PDF metadata when archiving. Title, author and producer are exactly what an archive needs; turn them off when they get in the way.
- Extract a page range first on long PDFs. A small test tells you whether heading detection is working before you process 500 pages.
- Validate the XML. The output is well-formed XML; open it in any XML-aware editor or run it through a validator against your target schema.
- Compress the source PDF first. Smaller PDFs convert faster. Run them through our Compress PDF tool.
Common problems and quick fixes
| Problem | Likely cause | Fix |
|---|---|---|
| Preview is empty | The PDF is scanned or image-only | Run it through an OCR tool first, or test by selecting text in a viewer. |
| Headings detected in body text | Large line-height body font | Toggle heading detection off and compare. |
| Paragraphs split at wrong places | Unusual line spacing in the source PDF | Toggle paragraph grouping off to keep every line separate. |
| Characters look wrong | Font has no Unicode map | This is a PDF-internal limitation. An OCR pass that reconstructs text from glyph images can recover it. |
| Only some pages convert | Page range excludes pages, or some pages are scanned | Set Page range to All pages and compare. |
| Cloud import fails | The sign-in window was blocked | Allow pop-ups for this site, then press the Drive or Dropbox button again. |
Related PDF tools
These pair naturally with PDF to XML and are all free.
Frequently asked questions
Is the PDF to XML converter really free?
Does the tool upload my PDF to a server?
Can I import PDFs from Google Drive or Dropbox?
What are the four XML schemas?
What kind of PDFs convert best?
Does it support OCR for scanned PDFs?
How are headings detected?
Are tables and columns preserved in the XML?
Can I convert only specific pages?
Will accents and special characters survive?
What is pretty-print, and why would I turn it off?
Is the output valid XML?
Can I copy the XML instead of downloading it?
Does it work on iPhone and Android?
How large can the PDF be?
Is the tool safe for confidential documents?
Ready to convert your PDF to XML?
Load a text-based PDF, pick a schema, and copy or download structured XML in seconds. Free, private and built for every device.
Convert PDF to XML