How do I keep spam out of my website contact form?
Short answer
Use three layers: a hidden honeypot field, a free Cloudflare Turnstile widget (up to 20 widgets per free account), and a server-side check of the Turnstile token within 300 seconds. The widget alone protects nothing, because the token must be verified on your server.
On this page
Why does my form get spam?
Bots find forms by crawling and fill in every field they see, then submit. A form with no protection is just an open mailbox, so the cost of spam is your time sorting real quote requests from junk, and the risk that a real customer's message gets buried.
Three layers work better than one, because each stops a different kind of bot: a hidden field catches simple bots, a challenge catches many scripted ones, and a server check makes sure nobody skips the challenge by sending the form directly. None of them is perfect, so you also keep an easy way to spot junk and a plain email address on the page.
What is a honeypot field?
A honeypot is an extra field that real people never see but bots fill in. Add a text input named something tempting like "website2", hide it with CSS so it is off screen, and set it to tabindex="-1" and autocomplete="off" so keyboard users and password managers skip it. On the server, if the field has any value, quietly drop the message. Do not hide it with a visible label, and do not tell the sender it failed, because that teaches a bot what to change.
Honeypot pattern
Field name: company_url (or any tempting name)
Hidden off screen with CSS (not display:none alone)
tabindex="-1" autocomplete="off" aria-hidden="true"
Server rule: if company_url is not empty, return a normal "Thanks" page and do not send the email.
How do I add Cloudflare Turnstile?
Turnstile is Cloudflare's CAPTCHA alternative. Cloudflare's plans page (checked October 2026) lists a Free plan with up to 20 widgets per account, 10 hostnames per widget, unlimited challenges and 7 days of analytics. You do not have to proxy your site through Cloudflare to use it. The steps, from Cloudflare's get-started guide:
- In the Cloudflare dashboard, create a widget. You get a public sitekey and a private secret key.
- Add the script https:/
/ challenges. cloudflare. com/ turnstile/ v0/ api. js to your page. - Put <div class="cf-turnstile" data-
sitekey= "YOUR- SITE- KEY"> < / div> inside your form. Turnstile adds a hidden field named cf-turnstile-response that is submitted with the form (embedding guide). - On your server, send that token and your secret key to Siteverify (next section). This step is required.
Pick a mode that fits the page: Managed, Non-interactive or Invisible.
What does the server check look like?
Your server must POST to https:/
Server-side check in plain steps
1. Read the field cf-turnstile-response from the submitted form.
2. POST secret + response to https:/
3. If "success" is true, send the message. If not, show "Please try the check again" and keep the form text.
4. Never put the secret key in the page source.
How do I test it without getting blocked?
Cloudflare publishes dummy keys for testing on any domain, including localhost (testing guide). Use the visible sitekey 1x00000000000000000000AA (always passes) with the test secret 1x0000000000000000000000000000000AA to see the success path. Use sitekey 2x00000000000000000000AB (always fails) with secret 2x0000000000000000000000000000000AA to see how your form handles a failed check. Test secrets accept only the dummy token XXXX.DUMMY.TOKEN.XXXX, and production secrets reject it, so switch to your real keys before launch.
What does this look like on real sites?
- A contractor's quote form. Spam sends 20 junk messages a week and buries real jobs. Add the honeypot and Turnstile in Managed mode, and send a plain-text email to the owner and a copy to the lead database. See our contractor website guide for what a quote form should ask.
- A musician's booking form. Choose Invisible mode so fans on a phone never see a challenge, and keep an email address as backup so a venue can still reach you if the check fails.
- A salon. Use Non-interactive and set the message field to 1,000 characters so links and keyword stuffing are easier to spot.
- A restaurant with a catering form. Require a phone number and a date, which spam bots tend to fill with nonsense, and reject entries with more than two links.
Pair your form with an address on your own domain so alerts do not land in a free inbox that filters aggressively; our email at your domain post explains how.
What should I check before I launch the form?
Run this list once, with your real keys installed: 1. Submit the form normally and confirm the message arrives at the right inbox within a minute. 2. Fill the hidden honeypot field with a test value (using browser developer tools) and confirm no email is sent. 3. Wait six minutes after the widget loads, then submit. The token will have expired after 300 seconds, so confirm the visitor sees a friendly retry message and keeps their typed text. 4. Submit twice with the same token (refresh the response in developer tools). The second try should be refused, because a token can be validated once. 5. Open the page source and confirm the secret key is nowhere in it. Only the sitekey belongs in the HTML. 6. Add your phone number or email next to the form, so a customer is never stuck if the check fails.
Review the first week of messages. If real people are being blocked, check the widget mode and the hostnames on the widget, since the free plan allows 10 hostnames per widget. If junk still arrives, add one required field that bots tend to miss, such as a job date, rather than making the form longer for everyone.
From our side
The quote form on our own site works this way: Turnstile with a server-side check, and every request saved to a database so a real request is never lost to a filtered inbox. Launch ($549) includes a contact form and Grow ($1,099) adds online booking or quote requests, paid half at the start and half at launch.
Key takeaways
- 01Use three layers: honeypot, Turnstile, and a server-side check.
- 02The Turnstile widget alone protects nothing; the token must be verified at Siteverify.
- 03Tokens expire after 300 seconds, work once, and are up to 2,048 characters.
- 04Cloudflare's free plan allows up to 20 widgets and unlimited challenges.
- 05Test with Cloudflare's dummy keys before launch.
Quick answers
Is Cloudflare Turnstile free?
Cloudflare's plans page lists a free plan with up to 20 widgets per account, 10 hostnames per widget and unlimited challenges, checked October 2026.
Do I need my site on Cloudflare to use Turnstile?
No. Turnstile works on sites that are not proxied through Cloudflare, but you still need to verify the token on your server.
Why did my form say the check expired?
Turnstile tokens expire after 300 seconds and can only be used once, so a visitor who waits too long needs a new challenge.
Will a honeypot stop all spam?
No. It stops simple bots only, which is why we combine it with Turnstile and a server-side check.
Free tool
Inspect your domain’s published SPF, DMARC, DKIM, and MX records with the free Email & DNS Checkup.