---
title: "What Is Semi-Structured Data? Examples and Extraction"
description: "Semi-structured data has some organization, like tags or labels, but no fixed schema. Examples such as JSON, XML and invoices, and how to extract it."
url: https://www.docsumo.com/blog/semi-structured-data
updated: 2026-09-26
---

# What is semi-structured data? Definition, examples and extraction

For analysts, data engineers and operations teams: what semi-structured data is, how it differs from structured and unstructured data, real examples, and how to turn it into clean rows, including from documents.

[Ritu John](https://www.docsumo.com/blog-authors/ritu-john) · Updated Sep 26, 2026 · 4 min read

![Illustration titled "What is semi structured data?" showing code windows, a database, folders and a document flowing into storage](https://www.docsumo.com/blog/images/data-extraction--semi-structured-data-hero.webp)

## Key takeaways

- **Semi-structured data** has some organization, such as tags, keys or labels, but doesn't follow a fixed schema of rows and columns.
- Common examples are **JSON, XML, YAML, HTML, emails and log files**, plus business documents such as **invoices and bank statements**, which carry the same fields in different layouts.
- It sits between **structured data** (tables with a fixed schema) and **unstructured data** (free text, images, audio).
- Machine formats like JSON are extracted with **parsers**; documents need **OCR plus machine learning** to find the fields.
- The work is mostly **normalization**: flattening nested fields, handling optional keys, and mapping many layouts to one schema.

**Semi-structured data** is data that has some organization, such as tags, keys or labels that say what each value means, but doesn't follow a fixed schema of rows and columns. JSON, XML, emails and log files are classic examples. Business documents such as invoices, bank statements and pay stubs are semi-structured too: they always contain the same kinds of fields, but every issuer lays them out differently.

## Structured vs semi-structured vs unstructured data

| Type | Organization | Examples | How it's read |
| --- | --- | --- | --- |
| Structured | Fixed schema of rows and columns | Database tables, spreadsheets | SQL |
| Semi-structured | Tags or keys, flexible schema | JSON, XML, email, logs, invoices | Parsers for files; OCR and models for documents |
| Unstructured | No predefined organization | Contracts, images, audio, video | Search, NLP, machine learning |

For the full side-by-side, read [structured vs unstructured vs semi-structured data](https://www.docsumo.com/blog/structured-vs-unstructured-vs-semi-structured-data).

## Examples of semi-structured data

### JSON

Key-value pairs with nesting and lists. The format of most APIs, web apps and IoT devices.

### XML

Opening and closing tags describe a hierarchy. Common in enterprise integrations, e-invoicing and configuration.

### YAML

Indentation-based and human-readable, used for configuration files and data exchange.

### HTML

Tags describe presentation more than meaning, so pulling data from web pages needs scraping rules.

### Email

Headers (from, to, date, subject) are structured; the body is free text; attachments can be anything.

### Log files

Each line follows a pattern, but the fields vary by event.

### Business documents

Invoices, bank statements, pay stubs and tax forms carry predictable fields in unpredictable layouts.

### JSON example

```json
{
  "invoice_number": "INV-20431",
  "vendor": {"name": "Acme Supplies", "tax_id": "12-3456789"},
  "line_items": [
    {"description": "Paper, A4", "qty": 10, "amount": 45.00},
    {"description": "Toner", "qty": 2, "amount": 120.00, "discount": 10.00}
  ]
}
```

Only the second line item has a `discount`. That's the flexibility, and the challenge, of semi-structured data.

### XML example

```xml
<invoice number="INV-20431">
  <vendor>Acme Supplies</vendor>
  <total currency="USD">155.00</total>
</invoice>
```

### Log file example

```text
2026-08-14 10:15:20 INFO user_login username=jdoe ip=192.168.1.100
2026-08-14 10:15:24 WARN payment_retry order=88731 attempt=2
```

A bank statement is the document version of the same idea: it always has an account number, a period, opening and closing balances and transactions, but thousands of banks each use their own template.

## Why semi-structured data is useful

- **Flexible schema.** New fields can be added without redesigning a database.
- **Self-describing.** Keys and tags travel with the values, so data moves easily between systems.
- **Handles nesting.** An invoice with many line items fits naturally.

The cost is that reporting usually needs the data flattened into consistent tables first.

## How semi-structured data is stored

- **Document databases** such as MongoDB store each record as a JSON-like document with its own shape.
- **Relational databases with JSON columns**, such as PostgreSQL's `jsonb` type, mix fixed columns with flexible ones.
- **Data warehouses** support semi-structured types, so JSON can be queried with SQL.
- **Object storage and data lakes** keep raw files (JSON, XML, CSV, PDFs) until they're processed.

> **Docsumo for OCR & IDP**: [The Docsumo platform](https://www.docsumo.com/platform)
>
> Document AI, Case Management and Document Workflows in one product.

## How to extract semi-structured data

### From machine formats: parse and normalize

For JSON, XML and logs, parsers do the reading. The real work is normalization: flattening nested objects, handling optional fields, and producing consistent rows. This Python example (standard library only, Python 3.8+) turns the JSON invoice above into one row per line item:

```python
import json

raw = """{
  "invoice_number": "INV-20431",
  "vendor": {"name": "Acme Supplies", "tax_id": "12-3456789"},
  "line_items": [
    {"description": "Paper, A4", "qty": 10, "amount": 45.00},
    {"description": "Toner", "qty": 2, "amount": 120.00, "discount": 10.00}
  ]
}"""

invoice = json.loads(raw)
rows = [
    {
        "invoice_number": invoice["invoice_number"],
        "vendor": invoice["vendor"]["name"],
        "description": item["description"],
        "qty": item["qty"],
        "amount": item["amount"],
        "discount": item.get("discount", 0.0),  # optional field
    }
    for item in invoice["line_items"]
]
for row in rows:
    print(row)
```

Output:

```text
{'invoice_number': 'INV-20431', 'vendor': 'Acme Supplies', 'description': 'Paper, A4', 'qty': 10, 'amount': 45.0, 'discount': 0.0}
{'invoice_number': 'INV-20431', 'vendor': 'Acme Supplies', 'description': 'Toner', 'qty': 2, 'amount': 120.0, 'discount': 10.0}
```

### From documents: OCR, models and validation

A PDF or scanned statement has no keys to parse. Getting to JSON means classifying the document, reading it with OCR, locating fields and tables with models trained on many layouts, validating the values (do the transactions reconcile to the closing balance?), and sending low-confidence fields to a person.

**Account**

| Field | Extracted value |
| --- | --- |
| Account holder | Harbor Street Bakery LLC |
| Address | 118 Harbor St, Portland, ME |
| Bank name | First Midwest Bank |
| Account number | •••• 4821 |
| Account type | Business checking |
| Statement period | 2026-07-01 → 2026-07-31 |

**Balances**

| Field | Extracted value |
| --- | --- |
| Opening balance | 42,180.55 |
| Total deposits | 88,412.10 |
| Total withdrawals | 91,686.44 |
| Closing balance | 38,906.21 |
| Transaction count | 142 |

**Transactions**

| Field | Extracted value |
| --- | --- |
| Date | 2026-07-14 |
| Description | ACH DEPOSIT STRIPE PAYOUT |
| Amount | +3,284.10 |
| Debit / credit | Credit |
| Running balance | 51,902.44 |
| Category | Card processor payout |

*A semi-structured document becoming data: account details, balances and every transaction row land in named fields.*

That's what intelligent document processing platforms do. Docsumo reports 99% field-level accuracy on 250+ document types, including [invoices](https://www.docsumo.com/solutions/documents/invoices), [bank statements](https://www.docsumo.com/solutions/documents/bank-statements) and [pay stubs](https://www.docsumo.com/solutions/documents/pay-stubs), and returns JSON through its API and webhooks.

## Challenges with semi-structured data

- **Schema drift.** New or renamed keys break downstream code. Validate against a schema and alert on changes.
- **Nesting.** Deeply nested data is awkward in SQL and spreadsheets. Decide the grain, such as one row per line item, up front.
- **Inconsistent types.** The same field can arrive as a number in one record and a string in another.
- **Layout variety in documents.** Templates don't scale across thousands of issuers; models do.
- **Quality.** Catch missing or wrong values before they reach reports, with [validation and review](https://www.docsumo.com/blog/human-in-the-loop-systems).

## The bottom line

Semi-structured data has labels but no fixed shape. For machine formats, parse it and normalize it into consistent tables. For business documents, the harder and more common case, use OCR and machine learning to find the fields, then validate them before they reach your systems.

[Book a demo](https://www.docsumo.com/book-a-demo) with a few of your own documents, or [start a free trial](https://www.docsumo.com/free-trial).

## Frequently asked questions

### What is semi-structured data in simple terms?

Data that has labels or tags describing what each value is, but not a fixed table layout. A JSON file is a good example: each value has a key, but different records can have different keys.

### Is a PDF invoice semi-structured data?

In document processing, yes. Every invoice has the same kinds of fields (vendor, date, total, line items), but each vendor lays them out differently. That's why template-based OCR struggles with invoices and machine learning handles them better.

### Is email structured or semi-structured?

Semi-structured. Headers such as sender, recipient, date and subject are structured fields, while the body is free text.

### Is CSV semi-structured?

CSV is usually treated as structured, because every row shares the same columns. In practice, inconsistent exports with missing columns or mixed formats behave like semi-structured data.

### How do you store semi-structured data?

In document databases such as MongoDB, in JSON columns in relational databases such as PostgreSQL, in data warehouses that support semi-structured types, or as raw files in object storage and data lakes.

**Sources**

1. [IETF RFC 8259: The JSON data interchange format](https://www.rfc-editor.org/rfc/rfc8259)
2. [W3C: Extensible Markup Language (XML) 1.0](https://www.w3.org/TR/xml/)
3. [PostgreSQL documentation: JSON types](https://www.postgresql.org/docs/current/datatype-json.html)
4. [Python documentation: json module](https://docs.python.org/3/library/json.html)

First published Apr 16, 2024. Last updated Sep 26, 2026.

**Written by** [Ritu John](https://www.docsumo.com/blog-authors/ritu-john) · Digital Content Expert, Docsumo

Ritu is a seasoned writer and digital content creator with a passion for exploring the intersection of innovation and human experience. As a writer, her work spans various domains, making content relatable and understandable for a wide audience.

[LinkedIn](https://www.linkedin.com/in/ritujohn) · [All posts by Ritu](https://www.docsumo.com/blog-authors/ritu-john)

- [AI bank statement analysis: how it works and what you get from it](https://www.docsumo.com/blog/ai-bank-statement-analysis)
- [ACORD 25 data extraction: fields, checks and automation](https://www.docsumo.com/blog/acord-25-data-extraction)
- [What is file parsing? Techniques, tools and Python examples](https://www.docsumo.com/blog/file-parsing)

## Keep reading

- [Structured vs unstructured vs semi-structured data: differences and examples](https://www.docsumo.com/blog/structured-vs-unstructured-vs-semi-structured-data): For data, operations and IT teams: a clear comparison of the three data types, with examples, storage and analysis options, and what it takes to turn documents like invoices and bank statements into structured data.
- [What is data extraction? Definition, types, methods and examples](https://www.docsumo.com/blog/what-is-data-extraction): For operations, finance and data teams: what data extraction means, which method fits which source, and how it works on a real invoice.
- [Document analysis vs data extraction: what each one is, with examples](https://www.docsumo.com/blog/data-extraction-vs-document-analysis): For operations teams, analysts and students. What the two terms mean, how they differ, and how they work together in business and in research.

[More on OCR & IDP](https://www.docsumo.com/blog#posts-idp)

## Next steps

- [Book a demo](https://www.docsumo.com/book-a-demo)
- [Get a free trial (1,000 pages)](https://www.docsumo.com/free-trial)
- [Contact sales or support](https://www.docsumo.com/contact)
- [agents.md](https://www.docsumo.com/agents.md): connect Docsumo to your AI agent with Docsumo MCP
- [llms.txt](https://www.docsumo.com/llms.txt) lists the key pages; add .md to any page's URL for its Markdown copy
