0
HomeFree ToolsHTML Contact Form Code Generator
Generators · Free to use · No signup needed

HTML Contact Form Code Generator

Configure the fields you need and copy a clean, accessible HTML form. Works in any site — WordPress, Webflow, plain HTML, anything.

Want submissions without a server?

Plain HTML forms need a backend to receive emails. A LemForms contact form handles spam protection, email alerts and a submissions inbox, and embeds anywhere.

Create a hosted contact form free See the embeddable form builder

Generate contact form HTML code

Choose the fields your form needs, set the action, and copy the generated markup into your page. The output uses associated labels, native input types, and required attributes so it works without a JavaScript framework.

Use a POST action when a server or form backend will process submissions. Use mailto only for a quick prototype because it depends on the visitor having an email application configured.

The generator creates the form structure. Add your own CSS or target the included class names to match the surrounding website.

Contact form HTML code example

This is the smallest contact form worth publishing: a name, an email address and a message, each with a label, sent by POST.

<form action="https://example.com/contact" method="post">
  <label>
    <span>Name *</span>
    <input type="text" name="name" required />
  </label>
  <label>
    <span>Email *</span>
    <input type="email" name="email" required />
  </label>
  <label>
    <span>Message *</span>
    <textarea name="message" rows="5" required></textarea>
  </label>
  <button type="submit">Send message</button>
</form>
What each part of the contact form HTML does
CodeWhat it does
actionThe URL that receives the submission. Swap it for your own endpoint or form backend.
method="post"Sends the values in the request body instead of the address bar, which is what you want for personal data.
<label>Ties the visible text to its input, so screen readers announce it and tapping the text focuses the field.
type="email"Checks the format in the browser and shows the email keyboard on phones.
nameThe key your server receives for each value, such as name, email and message.
requiredStops the form being sent while the field is empty. Validate again on the server.

The generator above builds the same structure with the fields you tick, plus a small stylesheet you can keep or replace.

  • HTML contact form template (plain HTML and Tailwind)
  • Honeypot field generator

Connect the HTML form to email or a backend

A browser cannot send a reliable email from HTML alone. Point the form action at your own endpoint or a hosted form backend, then validate and sanitise every submitted value on the server.

Keep the method set to POST for personal data, show a clear success state, and return useful validation errors when a field is missing.

If you do not want to maintain a submission endpoint, build the form in LemForms and embed it on the same page.

Make a contact form accessible and spam-resistant

Keep every visible field label connected to its input, preserve a logical keyboard order, and make error messages specific to the field that needs attention.

Add a hidden honeypot and server-side rate limiting to reduce automated spam. Do not rely on client-side required attributes as the only validation layer.

Test the finished form with a keyboard and at a narrow mobile width before publishing it.

Frequently asked questions

Where do submissions go?

With the mailto: action they open the user's email client. For real server-side delivery, point the action at a form backend like LemForms.

Is the generated HTML accessible?

Yes — labels are correctly associated, required fields are marked, and the markup is keyboard-navigable.

Can I style it?

Yes. The output uses simple class names so any CSS framework (Tailwind, Bootstrap, your own) can target it.

Build the form behind the tool

LemForms is the form builder this tool plugs into — calculations, conditional logic, embeds, webhooks, and a real submissions dashboard. Free to start.

Try LemForms free

More free tools

  • QR Code Form Generator
    Paste a form URL and download a QR code as PNG or SVG. Perfect for events, posters, table tents, and packaging. Free.
  • Honeypot Field Generator
    Generate a hidden honeypot field that blocks 90%+ of form spam bots — no CAPTCHA, no user friction, no third-party scripts.
  • Form Embed Code Generator
    Paste any form URL and get copy-paste embed code for WordPress, Webflow, Framer, Wix, Squarespace, Shopify, Notion and more.
  • NPS Score Calculator
    Calculate your Net Promoter Score in seconds. Enter promoters, passives, and detractors — get NPS, percentage breakdown, and industry context.
Fields
<form action="mailto:you@example.com" method="post" enctype="text/plain" class="lf-form">
  <label class="lf-field">
    <span>Name *</span>
    <input type="text" name="name" required />
  </label>
  <label class="lf-field">
    <span>Email *</span>
    <input type="email" name="email" required />
  </label>
  <label class="lf-field">
    <span>Subject</span>
    <input type="text" name="subject" />
  </label>
  <label class="lf-field">
    <span>Message *</span>
    <textarea name="message" rows="5" required></textarea>
  </label>
  <button type="submit">Send message</button>
</form>

<style>
  .lf-form { display: grid; gap: 1rem; max-width: 480px; font-family: system-ui, sans-serif; }
  .lf-field { display: grid; gap: .35rem; }
  .lf-field span { font-size: .875rem; font-weight: 600; color: #111; }
  .lf-field input, .lf-field textarea {
    padding: .65rem .85rem; border: 1px solid #d4d4d8; border-radius: .5rem; font: inherit;
  }
  .lf-form button {
    padding: .75rem 1.25rem; border: 0; border-radius: .5rem; background: #FFD93D;
    color: #111; font-weight: 600; cursor: pointer;
  }
</style>