HTML Contact Form Generator
Generate the HTML for a contact form with name, email and message fields, ready to paste into your site. Copy the code and wire it to your backend.
HTML
—
Contact forms that actually convert
A contact form is usually the single highest-leverage conversion point on a small site — it is how leads, support requests and partnership inquiries reach you. The math is brutal: industry studies put form abandonment rates around 67–81%, and the most consistent predictor is field count. Cutting one optional field can lift completions by double-digit percentages. Start from the smallest possible form (name, email, message) and only add fields you will actually act on.
A reasonable HTML5 baseline looks like this:
<form action="/contact" method="post">
<label for="name">Name</label>
<input id="name" name="name" required autocomplete="name">
<label for="email">Email</label>
<input id="email" name="email" type="email" required autocomplete="email" inputmode="email">
<label for="msg">Message</label>
<textarea id="msg" name="message" required minlength="20"></textarea>
<button type="submit">Send</button>
</form>
Where the form sends data
If you do not run a backend, plug into a form-to-email service. Popular options: Netlify Forms (drop a netlify attribute, zero code), Formspree, Getform, Web3Forms, Basin and Formcarry. With a real backend (Express, Rails, Laravel, Next.js Route Handler), POST to your own endpoint and validate again server-side — client validation is for UX, server validation is for trust.
Spam prevention without ruining UX
reCAPTCHA v3 (invisible) is the historical default, but it ships Google tracking and is increasingly being replaced by Cloudflare Turnstile (privacy-friendly, free) and hCaptcha. Even simpler: a honeypot field hidden via CSS that bots fill and humans never see, plus a minimum time-on-page check (less than 2 seconds = bot). These two techniques alone block 80–95% of automated spam without a single CAPTCHA challenge for legitimate users.
Accessibility and mobile UX
- Every input needs a real
<label for>— placeholder is not a label. - Use
aria-required="true"and togglearia-invalid="true"on validation errors. - Set
autocompleteattributes (name,email,tel) — autofill alone improves completion rates. - Set
inputmode="email",inputmode="tel"orinputmode="numeric"for the right mobile keyboard. - Inline error messages right below the field, not in a list at the top of the form.
- Move focus to the first error after submit so keyboard and screen-reader users land on it.
Privacy, GDPR and LGPD
Display a short consent message linking to your privacy policy near the submit button. A newsletter opt-in must be a separate, unchecked-by-default checkbox — bundling marketing consent with the contact request is illegal under GDPR and LGPD. Storage of the submission falls under data processing rules: spell out the retention period and the user's right to deletion in your policy.
FAQ
Do I need reCAPTCHA? No. Honeypot plus time-on-page covers most spam; Turnstile or hCaptcha are better than reCAPTCHA when you do need a challenge.
How many fields are too many? Each extra field measurably lowers conversion. Start at three (name, email, message) and add fields only when removing them would make your follow-up impossible.
Is newsletter opt-in mandatory? No — and bundling it with the contact form violates GDPR/LGPD. Keep marketing consent as a separate, opt-in checkbox.
Should I auto-save drafts to localStorage? For long forms (5+ fields) yes; for a quick contact form it is overkill and can leak previously typed content on shared computers.
Related Tools
HTML Form Generator from JSON
Read a JSON schema with fields (label, name, type, required) and generate a complete HTML form with styled inputs and validation attrs.
HTML Certificate Generator
Generate a printable HTML completion certificate with name, course and date. Customize the text and print or save it straight from your browser.
Fake Resume CV Generator
Generate a complete fake resume (CV) with name, experience, education and skills. Great for job portal prototypes, mockups and layout testing.
HTML Cookie Banner Generator
Generate an HTML cookie consent banner with an accept button, ready to paste into your site and help with GDPR and privacy compliance.
link prefetch Tag
Build <link rel="prefetch"> for early resource fetching.
HTML 404 Page Generator
Generate a ready-to-use HTML 404 error page with a clean layout and a link back home. Customize the message and publish it on your site in minutes.