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
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.
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.
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.