---
title: "Read key-value pair data from an image"
canonical_url: "https://www.nutrient.io/guides/dotnet/extraction/key-value-pairs/read-kvp-data-from-image/"
md_url: "https://www.nutrient.io/guides/dotnet/extraction/key-value-pairs/read-kvp-data-from-image.md"
last_updated: "2026-05-04T00:00:00.000Z"
description: "Extract structured key-value pair data from images using OCR in Nutrient .NET SDK."
---

# Read key-value pair data from an image

Key-value pair (KVP) extraction converts document images into structured data you can process in code.

Use this workflow when you need to:

- Extract labeled fields from forms and templates

- Reduce manual data entry from scanned documents

- Prepare OCR output for downstream systems

## Project setup

Install:

- The core Nutrient Native SDK package

- `GdPicture.Resources` for OCR and data extraction support

## Prepare the project

Register the SDK license before running OCR operations. For setup details, refer to the [getting started with.NET SDK](https://www.nutrient.io/sdk/dotnet/getting-started.md) guide.

```csharp

using GdPicture14;
using System.Text.RegularExpressions;

LicenseManager licence = new LicenseManager();
licence.RegisterKEY(""); // Set your license key

```

## Create the extraction components

Create image and OCR instances:

```csharp

using GdPictureImaging imaging = new GdPictureImaging();
using GdPictureOCR ocr = new GdPictureOCR();

```

## Load and analyze the image

Load the source image, bind it to OCR, and run OCR:

```csharp

int imageId = imaging.CreateGdPictureImageFromFile(@"input_kvp.png");

ocr.SetImage(imageId);

string ocrResultId = ocr.RunOCR(OCRSpecialContext.None);

```

## Extract and post-process key-value data

Get KVP output and apply text cleanup:

```csharp

string result = Regex.Replace(ocr.GetKeyValuePairsData(ocrResultId), "Accuracy: \\d*%", string.Empty).Replace("\r", "").Replace(" | ", " ");

string[] lines = result.Split('\n');

```

This produces line-based KVP output ready for parsing into storage or API payloads.

## Data extraction capabilities

The SDK supports scenarios such as:

- Label-value pairing from forms

- Table-like layout extraction

- Text normalization for cleaner output

- Confidence-oriented OCR workflows

## Conclusion

This workflow runs OCR-based KVP extraction on an image and returns structured text for automation workflows.
---

## Related pages

- [How key-value pair extraction works](/guides/dotnet/extraction/key-value-pairs.md)
- [Understand confidence scores in KVP extraction](/guides/dotnet/extraction/key-value-pairs/confidence-score.md)
- [Key-value pair extraction methods](/guides/dotnet/extraction/key-value-pairs/data-model.md)
- [Key-value pair extraction data types](/guides/dotnet/extraction/key-value-pairs/data-types.md)
- [Extract key-value pairs with our .NET SDK](/guides/dotnet/extraction/key-value-pairs/kvp-overview.md)

