Skip to content
Verity Teknologi
Panduan Published November 20, 2026

How KTP OCR Works: 5 Steps from Photo to Data (Complete Guide + Sample Output)

How KTP OCR works in 5 steps: image input, preprocessing, AI OCR, mapping NIK/name/address fields, and validation — with a flow diagram and sample output.

by Verity Teknologi

Diagram 5 langkah cara kerja OCR KTP: input gambar, preprocessing, AI OCR, pemetaan field, validasi dan output

KTP OCR works in 5 steps: capture a photo or scan of the ID card, clean up the image (preprocessing), run an AI OCR engine to read the text, map the results to data fields such as NIK, name, date of birth and address, then validate the data before sending it to your system. With AI-based OCR the whole flow runs automatically in seconds, so staff no longer retype ID card data.

5-step diagram of how KTP OCR works: image input, preprocessing, AI OCR, field mapping, validation and output
Verity KTP OCR pipeline: from an ID photo to structured data in 5 steps.

Step 1: Prepare the KTP image input

Input quality drives output quality. The KTP may come from a mobile app photo (eKYC), a branch scan, or an uploaded PDF.

  • Use a sharp photo with minimal glare on the lamination.

  • Make sure the whole card is visible — all four corners in frame.

  • Common formats: JPG, PNG, or PDF. Modern phone cameras usually provide enough resolution.

Step 2: Preprocess the image

Before reading, the image is cleaned up so the text is easy to recognize.

  • Detect and crop the card from the background.

  • Correct perspective if the KTP was photographed at an angle.

  • Fix rotation, contrast, and noise — for example grayscale, denoising, or thresholding to sharpen letters and digits.

With AI-based OCR, the model handles most of this, so even medium-quality photos can be read.

Step 3: Run the AI OCR engine

The OCR engine reads all the text on the card. AI OCR does not just recognize characters — it understands the KTP layout, making it more robust to skewed photos, shadows, or glare. Every reading comes with a confidence score.

Step 4: Map the results to structured fields

The raw text is then mapped to the fields your system needs:

  • NIK (16 digits)

  • Full name

  • Place and date of birth

  • Sex and blood type

  • Address, RT/RW, village, district

  • Religion, marital status, occupation, nationality

The result is structured data (for example JSON) that can be sent straight to other applications.

Sample KTP OCR output: fictional specimen ID card on the left, extracted NIK, name, birth date and address with confidence scores on the right
Sample KTP OCR result on a fictional specimen — every field carries a confidence score; fields below the threshold are flagged for review.

Step 5: Validate the data and send it to your system

OCR output should be validated before it drives business decisions:

  • NIK format: 16 digits, with the first 6 digits encoding the region (province, regency/city, district).

  • Birth date consistency: digits 7–12 of the NIK encode the date of birth (for women, the day is increased by 40) — it must match the date of birth that was read. Learn more in automatic KTP NIK validation.

  • Confidence threshold: low-confidence fields go to staff for review (human-in-the-loop).

Once validated, the data is sent via API to core banking, the loan origination system, or the onboarding app. See our OCR API integration guide.

How fast and how accurate is KTP OCR?

In Verity's live OCR demo, a document is extracted in about 3 seconds — from upload to structured data on screen. For production deployments, Verity targets 99%+ accuracy on the main KTP fields, with automatic validation and human review for low-confidence fields.

Tips for accurate KTP OCR results

  • Ask users to photograph the KTP on a flat surface with even lighting.

  • Show a camera guide frame in the mobile app.

  • Automatically reject photos that are too blurry before processing.

  • Always validate the NIK and date of birth instead of relying on the reading alone.

KTP data security

A KTP contains personal data protected by Indonesia's Personal Data Protection Law (UU PDP No. 27/2022). Make sure data is encrypted in transit and at rest, access is restricted, and your OCR vendor offers on-premise or private cloud options where required. See also KTP OCR: accuracy and data security.

Try it yourself

Want to see these steps on your own documents? Try the free OCR demo or explore Verity OCR KTP & NPWP for onboarding and eKYC.

Frequently asked questions

How does KTP OCR work?

KTP OCR works in 5 steps: capture a photo or scan, preprocess the image, run an AI OCR engine, map the text to fields such as NIK and name, then validate the data before sending it to your system.

What is KTP OCR?

KTP OCR is technology that reads the text on a photo or scan of an Indonesian ID card and turns it into structured data automatically, without manual entry.

How long does KTP OCR take?

With AI OCR a document usually takes seconds. In Verity’s live demo, extracting one document takes about 3 seconds.

How do you validate KTP OCR results?

Check the 16-digit NIK and its region code, match the date of birth against digits 7–12 of the NIK, and route low-confidence fields to staff for review.

Is KTP OCR safe for personal data?

Yes, if data is encrypted, access is restricted, and processing complies with UU PDP. Banks should choose a vendor offering on-premise or private cloud options.

Ready to automate your document processing?

Book a short demo. We’ll show how Verity extracts data from your documents — on your real use case.