What is a honeypot CAPTCHA?
A honeypot CAPTCHA is a form field that people never see but bots do. A spam bot that fills in every field it finds also fills in the hidden one, and your server rejects the submission. The visitor solves nothing and notices nothing.
The name comes from security, where a honeypot is a decoy that lures attackers the way honey lures flies. Strictly speaking it is not a CAPTCHA, because nobody is tested: the trap is set for the bot, and a person never touches it. People call it one because it does the same job on a form.
How a honeypot field works
- You add an extra input to the form, for example a field named
website. - You hide it with CSS, so it is not on screen. A visitor never sees it and leaves it empty.
- A bot that reads the HTML and fills in every input fills in this one too.
- Your server checks the field. If it has a value, the submission is spam, and you reject it or drop it quietly.
The check has to run on the server. A honeypot that is only checked in JavaScript does nothing against a bot that posts the form directly.
A common addition is a second trap: time. A person needs a while to read and fill in a form, a script needs a fraction of a second. If a submission arrives faster than anyone could type it, treat it as automated.
How to add a honeypot to your form
You need three pieces: the field, the CSS that hides it, and the check on your server.
<div class="hp-field" aria-hidden="true">
<label for="website">Leave this field empty</label>
<input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
</div>.hp-field {
position: absolute;
left: -9999px;
}// Reject the submission if the hidden field is missing or filled in
if (!isset($_POST['website']) || $_POST['website'] !== '') {
http_response_code(400);
exit;
}A few details decide whether it works:
- Hide the field with a class in your stylesheet, not with
type="hidden"or an inline style. Many bots skip hidden inputs, and some read inline styles. aria-hidden="true"andtabindex="-1"keep screen reader and keyboard users out of the field, and the label tells anyone who reaches it to leave it empty.autocomplete="off"and a name that does not look like an address or email field make it less likely that browser autofill fills it in.- Check that the field is present and empty. Otherwise a bot that posts straight to your endpoint without the field passes.
- Do not tell the bot why it failed. A generic error, or a normal thank-you page, gives a bot author nothing to tune against.
Some form plugins and frameworks have a honeypot option built in, so check yours before you write one.
What a honeypot stops, and what it misses
A honeypot is good at one thing: generic spam bots that crawl the web for forms and fill in every field they find. They send much of the junk that reaches contact forms and comment sections, and the honeypot catches them at no cost.
It misses three kinds of attacker:
- Bots that run a real browser. A headless browser renders the CSS, sees that the field is off screen and leaves it alone.
- Bots written for your site. Someone who looks at your form once will see the trap and leave the field out.
- People. Paid spammers and CAPTCHA farms fill in what a person sees, and a person does not see the honeypot.
It also does nothing against attacks that send exactly the fields a real user would. Credential stuffing on a login form, fake signups and bots testing stolen cards fall into that group. For those you need rate limits, proof-of-work or a bot score. Our page on CAPTCHA alternatives shows how those methods fit together.
Honeypot vs reCAPTCHA
A honeypot is free, invisible and private, and it only catches careless bots. reCAPTCHA catches more, including many bots in real browsers, but Google receives data about your visitors, a cookie is set, and reCAPTCHA v2 shows image puzzles when it is unsure. Which one fits depends on what is attacking your form.
| Honeypot field | Google reCAPTCHA | |
|---|---|---|
| What the visitor does | Nothing | v2: a checkbox, and images when unsure; v3: nothing |
| What it stops | Bots that fill in every field | Simple bots, plus automated browsers that Google's risk analysis flags |
| What it misses | Bots that render the page or were built for your site | Bots that pass as human, and people paid to solve challenges |
| What your server gets | A field that is empty or filled in | v2: pass or fail; v3: a score from 0.0 to 1.0, default threshold 0.5 |
| Data sent to a third party | None | Visitor data goes to Google; location varies, needs a legal review |
| Cookies | None | _GRECAPTCHA, which Google calls necessary |
| Cost | Free | Free up to 10,000 assessments a month per organization, then an $8 flat fee up to 100,000 |
| Who maintains it | You |
Use a honeypot on its own when the form is low value and the spam is generic. Use a CAPTCHA when bots keep coming after you added the honeypot, or when the form protects something worth attacking: a login, a signup, a checkout. The two also work well together. The honeypot catches the cheap bots, and the CAPTCHA only has to deal with the rest.
If Google is the reason you are reading about honeypots, there is a middle option. An invisible CAPTCHA with proof-of-work catches bots that render the page without showing visitors a puzzle, and some providers process data in the EU and set no cookies. Our list of reCAPTCHA alternatives compares seven of them, and Is reCAPTCHA GDPR compliant? covers the privacy side.
Can a honeypot block real visitors?
Yes, if it is built carelessly. Three things tend to go wrong:
- Autofill. Browsers and password managers fill in fields they recognize. A honeypot named
email2orphonemay get filled in for a real visitor, who is then rejected without knowing why. - Screen readers. A field that is only hidden visually can still be announced, and a blind visitor may fill it in because the form seems to ask for it.
aria-hidden="true"on the wrapper and a label that says “leave this field empty” prevent that. - Keyboard navigation. Without
tabindex="-1", someone tabbing through the form lands in a field they cannot see.
Log rejected submissions for a while after you add the honeypot. If real messages show up there, the field is not hidden well enough.
When is a honeypot enough?
A honeypot on its own is enough when the form is a contact, comment or newsletter form with modest traffic, the spam you get is generic (ads, links, nonsense) rather than aimed at your site, and a spam message that slips through is a nuisance, not a loss.
It is not enough for logins, signups, password resets or checkouts. Bots attack those because there is something to gain, and whoever runs them will take the minute it needs to skip a hidden field. It is also not enough once spam keeps arriving after you added it: that is the sign that the bots render your page. At that point add rate limits and an invisible CAPTCHA, and keep the honeypot as the first layer. For contact forms specifically, our page on form spam protection goes into more detail.
If you would rather keep everything on your own servers, our guide to open source CAPTCHA compares the self-hosted options.
Where TrustCaptcha fits
TrustCaptcha builds several honeypot fields into its widget, so you get the trap without writing it. They work next to proof-of-work, which the browser solves in the background on every plan and which gets harder with the risk of the request. From the Solo plan, each request also gets a bot score. Visitors solve nothing: the widget starts on its own.
TrustCaptcha sets no cookies, processes data in EU data centers and includes a Data Processing Agreement for every customer. A honeypot of your own still works fine next to it.
Try TrustCaptcha
Every plan starts with a 14-day free trial, and non-commercial websites can use TrustCaptcha for free with 500 verifications a month. Start your free trial and put it on the form where your honeypot stopped being enough.
