HTML Form Generator

Free HTML form generator. Add and edit fields, pick a theme and color, then copy the HTML, CSS and JavaScript, or a React, Next.js, Vue, Svelte or Astro component.

Free, no sign-up, runs in your browser. Updated

Picking another form replaces your changes.

Live preview

Let’s talk

Send us a message and we will get back to you soon.

Try it. The preview checks the fields like the real form, but nothing is sent.

Copy the form code

Pick your stack. Styled code matches the preview, with the fields, text, theme and color you set above. Unstyled code has the same fields as bare markup that picks up your own CSS, like Tailwind.

contact-form.html
<form id="nf-contact-form" class="nf-form" action="https://api.nisuform.com/s/YOUR_FORM_KEY" method="POST">
  <style>
#nf-contact-form {
  --nf-accent: #e60058;
  --nf-on-accent: #ffffff;
  --nf-text: #171717;
  --nf-muted: #525252;
  --nf-field: #f5f5f5;
  --nf-field-text: #171717;
  --nf-placeholder: #6b6b6b;
  --nf-control: #8a8a8a;
  --nf-error: #b91c1c;
  color-scheme: light;
  box-sizing: border-box;
  width: 100%;
  max-width: 480px;
  margin: 0;
  padding: 28px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #ffffff);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.12);
  color: var(--nf-text);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
}
#nf-contact-form *, #nf-contact-form *::before, #nf-contact-form *::after { box-sizing: border-box; }
#nf-contact-form [hidden] { display: none !important; }
#nf-contact-form .nf-title { margin: 0; font-size: 1.25em; font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; color: var(--nf-text); }
#nf-contact-form .nf-desc { margin: 6px 0 0; font-size: 0.9375em; color: var(--nf-muted); }
#nf-contact-form .nf-fields { display: grid; gap: 18px; margin-top: 22px; }
#nf-contact-form .nf-head + .nf-fields { margin-top: 22px; }
#nf-contact-form > .nf-fields:first-child { margin-top: 0; }
#nf-contact-form .nf-field { margin: 0; padding: 0; border: 0; min-width: 0; }
#nf-contact-form .nf-label { display: block; margin: 0 0 6px; padding: 0; font-size: 0.875em; font-weight: 600; color: var(--nf-text); }
#nf-contact-form .nf-req { color: var(--nf-muted); font-weight: 400; }
#nf-contact-form .nf-help { margin: 6px 0 0; font-size: 0.8125em; color: var(--nf-muted); }
#nf-contact-form .nf-input { display: block; width: 100%; margin: 0; padding: 10px 12px; border: 1px solid transparent; border-radius: 10px; background: var(--nf-field); color: var(--nf-field-text); font: inherit; font-size: 1em; line-height: 1.4; outline: 2px solid transparent; outline-offset: 1px; transition: border-color 150ms, box-shadow 150ms; }
#nf-contact-form input.nf-input, #nf-contact-form select.nf-input { height: 2.75em; padding-top: 0; padding-bottom: 0; }
#nf-contact-form textarea.nf-input { min-height: 112px; padding-top: 10px; padding-bottom: 10px; resize: vertical; }
#nf-contact-form .nf-input::placeholder { color: var(--nf-placeholder); opacity: 1; }
#nf-contact-form .nf-input:hover { border-color: color-mix(in srgb, var(--nf-text) 14%, transparent); }
#nf-contact-form .nf-input:focus { border-color: var(--nf-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nf-accent) 24%, transparent); }
#nf-contact-form .nf-input:user-invalid { border-color: var(--nf-error); }
#nf-contact-form .nf-input:user-invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--nf-error) 24%, transparent); }
#nf-contact-form .nf-input:-webkit-autofill { -webkit-text-fill-color: var(--nf-field-text); caret-color: var(--nf-field-text); box-shadow: inset 0 0 0 100px var(--nf-field); }
#nf-contact-form .nf-input:-webkit-autofill:focus { box-shadow: inset 0 0 0 100px var(--nf-field), 0 0 0 3px color-mix(in srgb, var(--nf-accent) 24%, transparent); }
#nf-contact-form input[type="number"].nf-input { -moz-appearance: textfield; appearance: textfield; }
#nf-contact-form input[type="number"].nf-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#nf-contact-form input[type="number"].nf-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#nf-contact-form input[type="date"].nf-input { min-width: 0; text-align: left; }
#nf-contact-form input[type="date"].nf-input::-webkit-date-and-time-value { text-align: left; }
#nf-contact-form input[type="date"].nf-input.nf-empty:not(:focus) { color: var(--nf-placeholder); }
#nf-contact-form input[type="date"].nf-input::-webkit-calendar-picker-indicator { margin: 0; padding: 4px; border-radius: 6px; opacity: 0.55; cursor: pointer; transition: opacity 150ms; }
#nf-contact-form input[type="date"].nf-input::-webkit-calendar-picker-indicator:hover { opacity: 1; }
#nf-contact-form select.nf-input { -webkit-appearance: none; appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23525252%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M6%209l6%206l6%20-6%22%2F%3E%3C%2Fsvg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px 16px; cursor: pointer; }
#nf-contact-form select.nf-input:has(option[value=""]:checked) { color: var(--nf-placeholder); }
#nf-contact-form select.nf-input option { color: var(--nf-field-text); }
#nf-contact-form .nf-options { display: grid; gap: 8px; }
#nf-contact-form .nf-option { display: flex; align-items: center; gap: 10px; min-height: 2.75em; margin: 0; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--nf-text) 14%, transparent); border-radius: 10px; background: transparent; color: var(--nf-text); font-size: 0.9375em; line-height: 1.4; cursor: pointer; transition: border-color 150ms, background-color 150ms; }
#nf-contact-form .nf-option:hover { border-color: color-mix(in srgb, var(--nf-text) 28%, transparent); }
#nf-contact-form .nf-option:has(input:checked) { border-color: var(--nf-accent); background: color-mix(in srgb, var(--nf-accent) 8%, transparent); }
#nf-contact-form .nf-option span { min-width: 0; overflow-wrap: anywhere; }
#nf-contact-form .nf-option input { -webkit-appearance: none; appearance: none; flex: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--nf-control); border-radius: 50%; background: transparent; outline: 2px solid transparent; cursor: pointer; transition: border-color 150ms, box-shadow 150ms; }
#nf-contact-form .nf-option input:checked { border-color: var(--nf-accent); background: radial-gradient(circle, var(--nf-on-accent) 0 3px, var(--nf-accent) 3.5px); }
#nf-contact-form .nf-option input:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--nf-accent) 24%, transparent); }
#nf-contact-form .nf-check { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: 0.9375em; line-height: 1.5; color: var(--nf-text); cursor: pointer; }
#nf-contact-form .nf-check input { -webkit-appearance: none; appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--nf-control); border-radius: 6px; background: var(--nf-field) center / 14px 14px no-repeat; outline: 2px solid transparent; cursor: pointer; transition: background-color 150ms, border-color 150ms, box-shadow 150ms; }
#nf-contact-form .nf-check input:checked { border-color: var(--nf-accent); background-color: var(--nf-accent); background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23ffffff%22%20stroke-width%3D%223.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M5%2012l5%205l10%20-10%22%2F%3E%3C%2Fsvg%3E"); }
#nf-contact-form .nf-check input:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--nf-accent) 24%, transparent); }
#nf-contact-form .nf-check input:user-invalid { border-color: var(--nf-error); }
#nf-contact-form .nf-rating { display: flex; flex-wrap: wrap; margin: 0 0 0 -4px; }
#nf-contact-form .nf-rating label { display: inline-flex; padding: 4px; border-radius: 8px; color: var(--nf-control); color: color-mix(in srgb, var(--nf-control) 45%, transparent); cursor: pointer; transition: color 150ms; }
#nf-contact-form .nf-rating svg { width: 30px; height: 30px; fill: currentColor; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; transition: transform 150ms; }
#nf-contact-form .nf-rating input:checked + label, #nf-contact-form .nf-rating label:has(~ input:checked) { color: var(--nf-accent); }
#nf-contact-form .nf-rating:hover input + label { color: var(--nf-control); color: color-mix(in srgb, var(--nf-control) 45%, transparent); }
#nf-contact-form .nf-rating:hover label:hover, #nf-contact-form .nf-rating:hover label:has(~ label:hover) { color: var(--nf-accent); }
#nf-contact-form .nf-rating label:active svg { transform: scale(0.88); }
#nf-contact-form .nf-rating input:focus-visible + label { outline: 2px solid var(--nf-accent); outline-offset: 0; }
#nf-contact-form .nf-file { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 112px; padding: 16px; border: 1.5px dashed var(--nf-control); border-color: color-mix(in srgb, var(--nf-control) 55%, transparent); border-radius: 10px; background: var(--nf-field); color: var(--nf-muted); text-align: center; transition: border-color 150ms, background-color 150ms, box-shadow 150ms; }
#nf-contact-form .nf-file-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
#nf-contact-form .nf-file svg { width: 22px; height: 22px; margin-bottom: 4px; }
#nf-contact-form .nf-file-text { margin: 0; max-width: 100%; font-size: 0.875em; overflow-wrap: anywhere; }
#nf-contact-form .nf-file-cta { font-weight: 600; color: var(--nf-text); }
#nf-contact-form .nf-file-types { margin: 0; font-size: 0.75em; color: var(--nf-placeholder); }
#nf-contact-form .nf-file:hover { border-color: var(--nf-control); }
#nf-contact-form .nf-file:focus-within { border-color: var(--nf-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nf-accent) 24%, transparent); }
#nf-contact-form .nf-file.nf-file-over { border-color: var(--nf-accent); background: color-mix(in srgb, var(--nf-accent) 8%, var(--nf-field)); }
#nf-contact-form .nf-file.nf-file-chosen { border-style: solid; border-color: var(--nf-accent); }
#nf-contact-form .nf-file.nf-file-chosen .nf-file-text { font-weight: 600; color: var(--nf-text); }
#nf-contact-form .nf-file:has(.nf-file-input:user-invalid) { border-color: var(--nf-error); }
#nf-contact-form .nf-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
#nf-contact-form .nf-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#nf-contact-form .nf-captcha { margin-top: 18px; }
#nf-contact-form .nf-submit { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; margin: 22px 0 0; padding: 10px 18px; border: 0; border-radius: 10px; background: var(--nf-accent); color: var(--nf-on-accent); font: inherit; font-size: 1em; font-weight: 600; cursor: pointer; transition: filter 150ms, transform 150ms; }
#nf-contact-form .nf-submit:hover { filter: brightness(0.94); }
#nf-contact-form .nf-submit:active { transform: scale(0.98); }
#nf-contact-form .nf-submit:focus-visible { outline: 2px solid var(--nf-accent); outline-offset: 3px; }
#nf-contact-form .nf-submit:disabled { opacity: 0.6; cursor: default; }
#nf-contact-form .nf-error { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--nf-error) 10%, transparent); font-size: 0.875em; color: var(--nf-error); }
#nf-contact-form.nf-sent { display: flex; flex-direction: column; justify-content: center; min-height: min(var(--nf-height, 0px), 440px); }
#nf-contact-form .nf-success { display: flex; flex-direction: column; align-items: center; padding: 20px 0; text-align: center; outline: none; }
#nf-contact-form .nf-success-icon { display: flex; flex: none; align-items: center; justify-content: center; width: 56px; height: 56px; margin: 0 0 20px; border-radius: 50%; background: var(--nf-accent); color: var(--nf-on-accent); box-shadow: 0 0 0 8px color-mix(in srgb, var(--nf-accent) 12%, transparent); }
#nf-contact-form .nf-success-icon svg { display: block; width: 28px; height: 28px; margin: 0; stroke-dasharray: 1; }
#nf-contact-form .nf-success-title { margin: 0; max-width: 24em; font-size: 1.125em; font-weight: 650; line-height: 1.35; letter-spacing: -0.01em; color: var(--nf-text); text-wrap: balance; overflow-wrap: anywhere; }
#nf-contact-form .nf-success-text { margin: 0; max-width: 30em; font-size: 0.9375em; line-height: 1.5; color: var(--nf-text); text-wrap: pretty; overflow-wrap: anywhere; }
#nf-contact-form .nf-success-title + .nf-success-text { margin-top: 6px; color: var(--nf-muted); }
#nf-contact-form.nf-sent .nf-success { animation: nf-success-in 400ms cubic-bezier(0.16, 1, 0.3, 1) both; }
#nf-contact-form.nf-sent .nf-success-icon { animation: nf-success-pop 500ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
#nf-contact-form.nf-sent .nf-success-icon path { animation: nf-success-draw 360ms 160ms cubic-bezier(0.65, 0, 0.35, 1) both; }
@keyframes nf-success-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes nf-success-pop { from { transform: scale(0.6); } }
@keyframes nf-success-draw { from { stroke-dashoffset: 1; } }
@media (prefers-reduced-motion: reduce) { #nf-contact-form * { transition: none !important; animation: none !important; } }
  </style>
  <div class="nf-head">
    <h2 class="nf-title">Let’s talk</h2>
    <p class="nf-desc">Send us a message and we will get back to you soon.</p>
  </div>
  <div class="nf-fields">
    <div class="nf-field">
      <label class="nf-label" for="nf-contact-form-name">Name<span class="nf-req" aria-hidden="true"> *</span></label>
      <input class="nf-input" id="nf-contact-form-name" name="name" type="text" autocomplete="name" placeholder="Jane Smith" required>
    </div>
    <div class="nf-field">
      <label class="nf-label" for="nf-contact-form-email">Email<span class="nf-req" aria-hidden="true"> *</span></label>
      <input class="nf-input" id="nf-contact-form-email" name="email" type="email" autocomplete="email" placeholder="jane@example.com" required>
    </div>
    <div class="nf-field">
      <label class="nf-label" for="nf-contact-form-message">Message<span class="nf-req" aria-hidden="true"> *</span></label>
      <textarea class="nf-input" id="nf-contact-form-message" name="message" rows="4" placeholder="Tell us about your project" required></textarea>
    </div>
  </div>
  <div class="nf-hp" aria-hidden="true"><input type="text" name="_gotcha" tabindex="-1" autocomplete="off"></div>
  <button class="nf-submit" type="submit">Send message</button>
  <p class="nf-error" role="alert" hidden></p>
  <div class="nf-success" role="status" tabindex="-1" hidden>
    <span class="nf-success-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" focusable="false"><path d="M5 12l5 5l10 -10" pathLength="1"/></svg></span>
    <p class="nf-success-title">Thanks!</p>
    <p class="nf-success-text">We got your message and will reply soon.</p>
  </div>
</form>
<script>
(function () {
  var form = document.getElementById("nf-contact-form")
  if (!form || !window.fetch) return
  var started = Date.now()
  var button = form.querySelector('.nf-submit')
  var error = form.querySelector('.nf-error')
  var success = form.querySelector('.nf-success')
  form.addEventListener('submit', function (event) {
    event.preventDefault()
    var data = new FormData(form)
    data.set('_elapsed', String(Date.now() - started))
    var label = button.textContent
    button.disabled = true
    button.textContent = 'Sending...'
    error.hidden = true
    fetch(form.action, {
      method: 'POST',
      headers: { Accept: 'application/json' },
      body: new URLSearchParams(data),
    })
      .then(function (response) {
        return response.json().catch(function () { return {} }).then(function (body) {
          if (!response.ok || !body.ok) throw new Error(body.message || 'Something went wrong. Please try again.')
        })
      })
      .then(function () {
        var redirect = form.getAttribute('data-redirect')
        if (redirect) {
          window.location.href = redirect
          return
        }
        form.style.setProperty('--nf-height', form.offsetHeight + 'px')
        Array.prototype.forEach.call(form.children, function (child) {
          if (child !== success && child.tagName !== 'STYLE') child.hidden = true
        })
        form.classList.add('nf-sent')
        success.hidden = false
        success.focus()
      })
      .catch(function (reason) {
        error.textContent = reason && reason.message ? reason.message : 'Something went wrong. Please try again.'
        error.hidden = false
      })
      .finally(function () {
        button.disabled = false
        button.textContent = label
        if (window.turnstile) window.turnstile.reset()
      })
  })
})()
</script>

Includes the CSS and a small script that sends the form without a page reload and shows the success message. HTML guide

Pasted into the code for you.

How to use the HTML form generator

  1. Pick a starting form

    Choose the form closest to what you need, like a contact, registration, survey or order form. Each one starts with its fields in place, and you can delete any you don't need.

  2. Edit the fields

    Open a field to change its label, type, placeholder, options or help text, or to make it required. Use the arrows to move it up or down, and add fields from the button at the bottom of the list. The Text tab sets the title, description, button label and the message people see after they send the form.

  3. Pick a theme and color

    Switch between the light, dark, paper and euphoria themes and choose an accent color. The preview works like the real form, so you can try the required fields and see the success message.

  4. Copy the code for your stack

    Pick HTML, React, Next.js, Vue, Svelte or Astro, then Styled or Unstyled, and copy the code into your page.

Field types

Every field gets a label and a name taken from that label, so Phone number becomes phone_number. The name is what the answer is sent under, and you can change it in the field's settings.

FieldHTML it generates
Short text<input type="text">
Long text<textarea>
Email<input type="email">
Phone<input type="tel">
Website<input type="url">
Number<input type="number">
Multiple choice<input type="radio"> inside a <fieldset>
Dropdown<select>
Checkbox<input type="checkbox">
Star rating<input type="radio"> from 1 to the number of stars
Date<input type="date">
File upload<input type="file">

Adding a file upload field also adds enctype="multipart/form-data" to the form, which browsers need to send files. See file uploads for size limits and plans.

What the generated code includes

This is the unstyled HTML for the contact form. It is a normal form that posts without any JavaScript.

contact-form.html
<form action="https://api.nisuform.com/s/YOUR_FORM_KEY" method="POST">
  <label>
    Name
    <input name="name" type="text" placeholder="Jane Smith" required>
  </label>
  <label>
    Email
    <input name="email" type="email" placeholder="jane@example.com" required>
  </label>
  <label>
    Message
    <textarea name="message" rows="5" placeholder="Tell us about your project" required></textarea>
  </label>
  <input type="text" name="_gotcha" tabindex="-1" autocomplete="off" style="display:none">
  <button type="submit">Send message</button>
</form>
  • Each input sits inside its label, so clicking the label focuses the field and screen readers announce it.
  • Required fields carry the required attribute, and email, phone and website fields use their own input types, so the browser checks them before sending.
  • The hidden _gotcha field is a honeypot. People never see it, bots fill it in, and those submissions are dropped. Read more about spam filtering.
  • The styled version adds the CSS in a style block scoped to the form, and a small script that sends the form without a page reload, shows the success message and sends how long the form was open, so forms filled faster than a person could type are dropped too.

Where the submissions go

An HTML form collects answers but can't deliver them. When someone presses the button, the browser sends the fields to the URL in the form's action attribute, and something at that URL has to save them and tell you. A static site has no server of its own to do that.

The generated code posts to a Nisuform endpoint, which checks each submission for spam, saves it to your inbox and emails it to you. The Free plan includes 100 submissions a month and 3 forms, and needs no credit card.

  1. Create a free form

    Sign up and create a form with Endpoint only. Copy the endpoint from its Setup tab. The last part is your form key.

  2. Add your key

    Type the key into the box under the code and copy the code again, or replace YOUR_FORM_KEY by hand.

  3. Send a test

    Publish the page and submit the form once. It appears in your inbox, and you get an email within seconds.

For the full setup on a static site, read how to add a contact form without a backend or the HTML forms guide.

Generator or a hosted form builder

Hosted form builders such as Google Forms, Jotform and Typeform keep the form on their own site. You share a link or embed the form, usually in an iframe, and its styling comes from their editor rather than your site's CSS.

The code from this generator becomes part of your page instead. The form sits in your layout, and you can change any part of the markup. A hosted builder is the better fit when you need logic that skips questions based on earlier answers, payments, or a form people open from a link without a website.

For a ready-made starting point with notes on each field, browse the free HTML form templates.

Frequently asked questions

Is this HTML form generator free?

Yes. It runs in your browser, nothing you type is sent to a server, and there is no sign-up. The code is yours to copy and change.

Can an HTML form send an email by itself?

No. HTML describes the fields and where the data goes, but a server has to receive the submission and send the email. The generated code posts to a Nisuform endpoint, which filters spam, saves each submission and emails it to you. A form with a mailto: action only opens the visitor's email app, and does nothing for people who read email in a browser.

What should the form action be?

The action is the URL that receives the submission. The generated code uses https://api.nisuform.com/s/YOUR_FORM_KEY. Create a free Nisuform form, type its key into the box under the code and copy the code again. You can also point the action at your own server, since the field names stay the same.

Does the form work without JavaScript?

Yes. The unstyled HTML version is a plain form that posts without any script. The styled version adds a small script that sends the form without a page reload and shows the success message in place. If the script does not run, the form still posts normally.

Can I add a file upload field?

Yes. Add a File upload field and the generator adds enctype="multipart/form-data" to the form for you. Receiving files with Nisuform needs the Pro plan, which accepts up to 5 files per submission.

Can I use the form in WordPress, Webflow or another site builder?

Yes. The HTML version works anywhere you can paste HTML, such as a WordPress Custom HTML block or a Webflow Embed element. If your site builder removes scripts, use the unstyled version, which works without JavaScript.

Can I style the form with my own CSS or Tailwind?

Yes. Switch the code to Unstyled to get bare markup with labels and named fields that picks up your own CSS. The styled version keeps its colors in CSS variables at the top of the style block, like --nf-accent, so you can change them by hand later.

Start collecting form submissions

Set up your forms with built-in spam protection in minutes for free.

Jane Smith

jane@smith.design

Live

12.4k

Submissions

24

Forms

0

Spam