Blog Layout

How to Automatically Fill Forms on Websites with AI

How to Automatically Fill Forms on Websites with AI

Sam Sarvas
Jan 22, 2024

As a marketer, you know that forms are a necessary evil - important for capturing user data but often lead to high abandonment rates.


In fact, up to 80% of users never complete long, complicated online forms according to Baymard Institute.


That's why automating form filling should be a top priority. 


If your in sales or marketing, this guide on using AI for client onboarding is a must read. 


You'll learn exactly how to personalize AI for clients.


For developers, AI and machine learning can help.


Open-source libraries like Tesseract OCR and OpenCV powered by Python let you implement AI form fillers on your site for free.


In this post, we'll look at the benefits of auto-filling forms with AI, review top open-source tools on GitHub, and walk through code examples to get started.

The Benefits of AI-Powered Form Filling

1.) Streamlined Data Collection

There are many advantages to taking an AI-first approach to filling out forms on your site:


  • Faster data collection. AI can input text, numbers, checkboxes at much higher speeds than humans, allowing you to swiftly gather information.


  • Lower abandonment rates. Long forms overwhelm users. AI auto-completion keeps them engaged and leads to higher form completion.


  • Fewer errors. Humans make typos and incorrect selections. AI follows logical patterns and rules to fill out forms accurately.


  • Smoother UX. auto-filling create a seamless, near-instant experience for users when submitting data.


  • Personalization. AI can pull data from existing user profiles and databases to prefill fields.


  • Works 24/7. AI form fillers provide consistency and don't need breaks.


  • Scalability. Once implemented, AI can handle increasing numbers of form submissions without getting overwhelmed.


  • Development speed. Open-source libraries accelerate deployment vs building from scratch.


  • Lower costs. AI is more affordable than large customer support or data entry teams.


For SaaS companies, implementing AI to automate data collection provides a better user experience, more sales, lower costs, and actionable insights.

The Top Open-Source AI Tools for Form Filling

A variety of open-source libraries available on GitHub can be used to apply AI and machine learning to filling out web forms automatically.


Here are some top options:

Fill Forms on Website with AI

1. Tesseract OCR

One of the most popular OCR libraries, Tesseract was originally developed by Hewlett Packard in the 1980s and open sourced by Google in 2005. It uses deep learning to recognize text in images and documents like scanned PDFs.


This allows it to "read" text-based CAPTCHA codes and convert them into inputtable text.


Tesseract supports over 100 languages out of the box. It can handle distorted or blurred text well. For form filling, it is great for bypassing CAPTCHAs and recognizing any required text-based fields.

2. OpenCV

OpenCV (Open Computer Vision Library) was created by Intel and released under an open-source BSD license. It provides pre-trained machine learning models for common computer vision tasks like object classification, face detection, image segmentation and more.


For filling out forms, OpenCV can identify and understand fields and sections in documents like tax forms, applications, and receipts. It can also detect checkboxes and whether they are checked or unchecked. This allows AI systems to logically fill out the right yes/no, male/female, agree/disagree type fields.

3. Roboflow

Roboflow provides a full computer vision and deep learning platform for classifying, recognizing, and processing images.


Under the hood it uses OpenCV and TensorFlow models. The Roboflow API makes it easy to upload images, generate labeled datasets, and train computer vision models.


For forms, Roboflow can build custom models to analyze form structure, extract fields and text, and recognize checkboxes or selections. It outputs metadata like field locations and boundaries for integration into automation scripts.

3. Python Libraries

Python has an extensive ecosystem of AI and automation focused libraries that can be used for form filling:


  • OpenCV - As covered above, the OpenCV library contains pre-trained computer vision models like Cascade Classifiers for identifying form fields.


  • PyTesseract - This is a Python wrapper for Google's Tesseract OCR engine. It simplifies calling Tesseract functions from Python code for text recognition.


  • pdf2image - This converts PDF documents into images that tools like Tesseract can then process for OCR.


  • PIL (Python Imaging Library) - For preprocessing images and preparing them for OCR and computer vision algorithms. Resizing, cropping, compression and more.


  • Pandas - Provides data structures and analysis for cleaning and preparing extracted form data for entry into databases.


  • Numpy - Powerful N-dimensional array manipulation capabilities for transforming image data.


  • Regex - Built-in regular expressions module can validate and normalize extracted form inputs.


Together these Python libraries cover the full pipeline - document processing, OCR, field detection, data extraction, post-processing and analysis. They allow developers to build custom form parsing solutions.

Step-by-Step Code Examples for Auto-Filling Web Forms with AI

To see how these pieces fit together, let's walk through some Python code for automatically filling out forms using AI and open-source libraries.


FYI - Our CRO agency can help your automation efforts.  CompleteCRO does conversion rate optimization for SaaS, including some automation setup.

Text Field Recognition with OpenCV + Tesseract

The first example uses optical character recognition to detect text fields in an image and automatically input values:

# Import Libraries 

import pytesseract

import cv2

from PIL import Image

import numpy as np


# Load the image and convert to grayscale

image = cv2.imread('form.jpg')

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


# Apply thresholding to isolate text

thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1] 


# Detect form contours and extract ROI

contours = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

roi = contours[0]


# OCR to extract text from ROI using pytesseract

text = pytesseract.image_to_string(roi)


# Type or paste extracted text into form fields

pyautogui.write(text)

This uses OpenCV for preprocessing and contour detection to isolate each text field. PyTesseract then extracts the text which can be automatically typed or pasted into the matching text fields on the web form.

Checkbox Detection with OpenCV Template Matching

For recognizing checkboxes and radio buttons, we can use template matching:

# Import Libraries

import cv2

import numpy as np



# Load form image and template checkbox image 

form = cv2.imread('form.jpg')

template = cv2.imread('checkbox.jpg')


# Convert images to grayscale

form_gray = cv2.cvtColor(form, cv2.COLOR_BGR2GRAY)

template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)


# Define matching method (TM_CCORR_NORMED recommended)

method = cv2.TM_CCORR_NORMED 


# Apply template matching to locate checkboxes

result = cv2.matchTemplate(form_gray,template_gray,method)

min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)


# Check if similarity score passes threshold 

if max_val >= 0.8:

  # Checkbox detected! Can perform click event to check/uncheck

  pyautogui.click(max_loc)


By comparing small template image patches, we can identify and interact with checkboxes and other GUI elements on a form.

Try Our AI Form Tool to Fine-Tune Content Based on Your Client's Data

While open source libraries allow you to build custom AI form filling solutions, if you are writing content for client's, you'll want a workflow you won't have to maintain.


Performify is like an AI google forms for marketers.


The AI analyzes form submissions and uses your data for to fine-tune AI content.


 generates highly relevant responses tailored to your business needs:


  • Sync up client info with ChatGPT for better AI accuracy
  • Optimize Writing Workflows, Avoid Client Clashes
  • Meet client expectations From the 1st draft
  • Connect Client Preferences with performance optimized writing

Start Using AI to Fill Out Website Forms Today

Implementing AI to automatically fill out web forms provides a long list of conversion, productivity, and performance benefits for SaaS businesses.


Machine learning powered form automation is fast, accurate, and creates a smoother experience for capturing customer data.


This guide provided a comprehensive look at using open-source Python libraries like OpenCV, Tesseract, and Roboflow for building AI-driven solutions.


With pre-trained computer vision and OCR models available today, it's possible to get automated form filling up and running quickly without reinventing the wheel.


The code examples demonstrate how these different tools can be combined to recognize text fields, detect checkboxes, extract data, and programmatically fill out both simple and complex web forms.


Adopting AI for repetitive data entry tasks allows your team to focus on more high-value and strategic initiatives.


And your customers will appreciate the frictionless, personalized web experiences powered by machine learning.


To discuss options for implementing AI-powered web form fillers on your site, contact our team of machine learning experts today. We're here to help you capture more conversions and deliver next-level customer experiences.

Photo Author Sam Sarvas

Sam Sarvas

CRO & Marketing Expert

Latest Blog Articles

ai customization techniques
10 Sep, 2024
Discover powerful AI customization techniques to transform your marketing strategy. Learn how to leverage your data for personalized, high-impact AI-driven campaigns.
Performance Marketing Client Onboarding
03 Sep, 2024
Get insights on 10 onboarding questions that performance marketers can use to boost client success. Discover tips and the best performance marketing form tools.
New Website Client Intake Surveys
03 Sep, 2024
Discover effective new website client intake surveys and questions. Boost project success with our guide to onboarding forms for digital marketing clients.
Share by: