HTML Form Generator [2025]

Tool rating: 0 people found this tool terrific

Visually build and style custom HTML forms. Add various field types, customize appearance, and generate ready-to-use HTML & CSS code.

✓ Add/Remove Fields✓ Multiple Field Types✓ Layout & Styling Options✓ Live Preview✓ HTML & CSS Output✓ CSS Variables Option
Full Nametext
Email Addressemail
Messagetextarea
Submit Formsubmit

Select a field above to edit its properties.

16px
1px
6px
10px
12px
10px
24px
6px

My Awesome Form

This is a static preview. Interaction styles (like focus) are applied via CSS.

<form action="/submit-handler" method="POST" class="form-container">
  <h2 class="form-title">My Awesome Form</h2>
  <div class="form-field form-field-text">
<label for="14d85174-dfe4-47e7-981f-dd828d199f19" class="form-label">Full Name<span class="required-indicator">*</span></label>
  <input type="text" id="14d85174-dfe4-47e7-981f-dd828d199f19" name="full_name" required placeholder="Enter your full name" class="form-input form-input-text">
</div>
  <div class="form-field form-field-email">
<label for="5cbaafb2-9875-441a-a186-6536165657f9" class="form-label">Email Address<span class="required-indicator">*</span></label>
  <input type="email" id="5cbaafb2-9875-441a-a186-6536165657f9" name="email" required placeholder="you@example.com" class="form-input form-input-email">
</div>
  <div class="form-field form-field-textarea">
<label for="8d106e89-7f04-47d5-8c5c-a379ce7405a5" class="form-label">Message</label>
  <textarea id="8d106e89-7f04-47d5-8c5c-a379ce7405a5" name="message" placeholder="Your message here..." rows="4" class="form-input form-textarea"></textarea>
</div>
  <div class="form-field form-field-buttons">
    <div class="form-field form-field-submit">
  <button type="submit" class="form-button form-button-submit">Submit Form</button>
</div>
  </div>
</form>

:root { /* Or scope to your form container, e.g., .form-container */
  --form-label-color: #374151;
  --form-label-weight: bold;
  --form-label-width: 30%; /* For inline layout */
  --form-field-spacing: 16px;
  --form-input-bg: #ffffff;
  --form-input-text: #1f2937;
  --form-input-border: #d1d5db;
  --form-input-border-width: 1px;
  --form-input-border-radius: 6px;
  --form-input-padding-v: 10px;
  --form-input-padding-h: 12px;
  --form-input-focus-border: #4f46e5;
  --form-input-focus-shadow: 0 0 0 3px #4f46e540; /* Add alpha for shadow */
  --form-button-bg: #4f46e5;
  --form-button-text: #ffffff;
  --form-button-padding-v: 10px;
  --form-button-padding-h: 24px;
  --form-button-border-radius: 6px;
  --form-button-weight: bold;
  --form-required-color: #dc2626; /* Example: red-600 */
}

/* --- Base Form Styling --- */
.form-container {
  width: 100%; /* Takes available width */
  max-width: 600px; /* Sensible default max-width */
  margin: 0 auto; /* Center the form */
  box-sizing: border-box; /* Ensure padding doesn't expand container */
}

.form-title {
  margin-bottom: calc(var(--form-field-spacing)px * 1.5); /* More space after title */
  font-size: 1.5em; /* Larger title */
  font-weight: bold;
  color: var(--form-label-color);
  text-align: center; /* Center title */
}

.form-field {
  margin-bottom: var(--form-field-spacing)px;
}
/* Remove margin from the last field */
.form-container > .form-field:last-child {
    margin-bottom: 0;
}


.form-label {
  display: block;
  margin-bottom: 6px; /* Consistent spacing below label */
  color: var(--form-label-color);
  font-weight: var(--form-label-weight);
  font-size: 0.9em;
  line-height: 1.4;
  cursor: default; /* Default cursor for labels */
}

.required-indicator {
  color: var(--form-required-color);
  margin-left: 4px;
  font-weight: bold;
}

/* General Input Styling (Text, Email, Password, etc., Textarea, Select) */
.form-input,
.form-textarea,
.form-select {
  display: block;
  width: 100%;
  padding: var(--form-input-padding-v)px var(--form-input-padding-h)px;
  background-color: var(--form-input-bg);
  color: var(--form-input-text);
  border: var(--form-input-border-width)px solid var(--form-input-border);
  border-radius: var(--form-input-border-radius)px;
  font-size: 1em;
  line-height: 1.5;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  box-sizing: border-box;
}

/* Specific overrides */
.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-select {
  appearance: none; /* Remove default dropdown arrow */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--form-input-padding-h)px center;
  background-repeat: no-repeat;
  background-size: 1.2em 1.2em;
  padding-right: calc(var(--form-input-padding-h)px * 2 + 1.2em); /* Make space for arrow */
}

/* Focus States */
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--form-input-focus-border);
  outline: 0;
  box-shadow: var(--form-input-focus-shadow);
}

/* --- Checkbox & Radio Specifics --- */
.form-checkbox-wrapper,
.form-radio-wrapper {
  display: flex;
  align-items: center;
  margin-bottom: 8px; /* Spacing between options */
}
.form-checkbox-wrapper:last-child,
.form-radio-group .form-radio-wrapper:last-child { /* Target last radio wrapper inside group */
  margin-bottom: 0;
}

.form-input.form-checkbox,
.form-input.form-radio {
  display: inline-block;
  width: auto; /* Reset width */
  height: auto; /* Reset height */
  margin-top: 0.2em; /* Align better with text */
  margin-right: 8px;
  flex-shrink: 0;
  vertical-align: middle; /* Align vertically */
  cursor: pointer;
  /* Consider adding custom styles here */
  appearance: none; /* Base for custom styles */
  background-color: var(--form-input-bg);
  border: var(--form-input-border-width)px solid var(--form-input-border);
  padding: 0; /* Remove padding */
  width: 1.1em; /* Custom size */
  height: 1.1em; /* Custom size */
  position: relative;
}
.form-input.form-checkbox {
  border-radius: var(--form-input-border-radius)px * 0.5; /* Slightly less round */
}
.form-input.form-radio {
  border-radius: 50%; /* Round */
}

/* Custom checkmark/dot */
.form-input.form-checkbox:checked::before {
  content: '';
  display: block;
  width: 0.6em;
  height: 0.6em;
  background-color: var(--form-button-bg);
  border-radius: 2px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.form-input.form-radio:checked::before {
  content: '';
  display: block;
  width: 0.6em;
  height: 0.6em;
  background-color: var(--form-button-bg);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.form-input.form-checkbox:focus,
.form-input.form-radio:focus {
   /* Apply focus styles */
   border-color: var(--form-input-focus-border);
   box-shadow: var(--form-input-focus-shadow);
}


.form-label-checkbox,
.form-label-radio {
  display: inline-block;
  margin-bottom: 0;
  font-weight: normal; /* Options usually normal weight */
  cursor: pointer;
  line-height: 1.5; /* Match input line-height */
  vertical-align: middle;
}

/* Radio Group Fieldset */
.form-radio-group {
  border: none;
  padding: 0;
  margin: 0;
}
.form-label-group { /* Legend styling */
  margin-bottom: 10px;
  font-weight: var(--form-label-weight);
  color: var(--form-label-color);
  font-size: 0.9em;
  padding: 0; /* Remove default padding */
}


/* --- Button Styling --- */
.form-button {
  display: inline-block;
  padding: var(--form-button-padding-v)px var(--form-button-padding-h)px;
  background-color: var(--form-button-bg);
  color: var(--form-button-text);
  border: none;
  border-radius: var(--form-button-border-radius)px;
  font-weight: var(--form-button-weight);
  font-size: 1em;
  line-height: 1.5;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s ease-in-out, opacity 0.15s ease-in-out;
  text-decoration: none; /* Remove underline */
}

.form-button:hover {
  opacity: 0.9;
}

.form-button-reset {
  background-color: #6b7280; /* Example: gray-500 */
  color: #ffffff;
}
.form-button-reset:hover {
  background-color: #4b5563; /* Example: gray-600 */
  opacity: 1;
}

/* Container for buttons */
.form-field-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start; /* Align buttons left by default */
}

/* --- Layout Specifics --- */

CSS Variables are defined at the top. Apply rules globally or scope them.

How to Use This Generator

  1. Configure Form Settings: Set the overall Form Title, Action URL (where data is sent), and Method (POST/GET).
  2. Manage Fields:
    • Use the "Add Field" dropdown to add new form elements (text, email, textarea, select, etc.).
    • Click on a field in the list to select it for editing.
    • Use the controls in the "Edit Field" section to modify the selected field's Label, Name, Type, Placeholder, Required status, and Options (for select/radio).
    • Use the up/down arrows to reorder fields and the trash icon to remove them.
  3. Customize Styling: Adjust layout (stacked/inline labels), spacing, colors, borders, padding, and button appearance in the "Styling Options" section. Choose whether to use CSS Variables in the output.
  4. Preview: Observe the live preview on the right to see how your form looks with the current settings and styles.
  5. Copy Code: Click the "Copy HTML" and "Copy CSS" buttons to get the generated code for your project.
  6. Implement: Paste the HTML into your web page and the CSS into your stylesheet. Ensure the form's `action` attribute points to a valid server-side script or endpoint to handle the submitted data.

Styling & Accessibility Tips

  • Use CSS Variables: Enabling CSS Variables makes it easier to integrate the form styles into your existing design system or theme. You can override the variables globally or locally.
  • Layout Choice: 'Stacked' labels are generally more mobile-friendly. 'Inline' labels save vertical space on wider screens but require careful alignment.
  • Keep it Consistent: Ensure padding, border-radius, and font sizes are consistent across all input types for a professional look.
  • Focus States: Clear `:focus` styles (like the border color and optional shadow provided) are crucial for keyboard navigation accessibility.
  • Labels are Key: Always use label elements correctly associated with their form controls using the `for` attribute matching the control's `id`. This is vital for screen readers.
  • Required Fields: Clearly indicate required fields visually (like the asterisk `*`) and use the `required` HTML attribute for browser-level validation.
  • Placeholders vs. Labels: Placeholders are hints, not replacements for labels. Labels should always be visible.
  • Error Handling: This generator provides the structure and base styling. You'll need to add server-side validation and potentially client-side JavaScript for displaying error messages effectively.

Comments

Please sign in to leave a comment

No comments yet

Be the first to share your thoughts! Your feedback helps us improve our tools and inspires other users.

More Code Tools

AVRO to JSON Converter

Convert AVRO to JSON

AVRO to Protobuf Converter

Convert AVRO to Protobuf

AVRO to XML Converter

Convert AVRO to XML code

Base64 to JSON Converter

Convert Base64 encode to JSON format

Base64 to XML Converter

Convert Base64 encode to XML format

Base64 to YAML Converter

Convert Base64 encode to YAML format

BBCode to HTML Converter

Convert Bulletin Board code to HTML

BSON to JSON Converter

Convert BSON to JSON

BSON to XML Converter

Convert BSON to XML

Code Difference Checker

Visually compare two blocks of code or text

Comment Remover

Remove comments from your codebase

CSON to JSON Converter

Convert CSON to JSON

CSS Animation Generator

Create CSS animations visually with presets and controls

CSS Arrow Generator

Create pure CSS arrows (triangles) using borders

CSS Background Generator

Generate pure CSS background patterns with customization

CSS Border Generator

Visually create CSS borders and border-radius styles

CSS Box Shadow Generator

Create adjustable box shadows using CSS

CSS Button Generator

Style buttons in different ways

CSS Checkbox Generator

Generate stylish custom CSS checkboxes with interactive controls

CSS Clip Path Generator

Create custom CSS clip-path shapes visually with presets

CSS Easing Generator

Visually create cubic-bezier easing functions with an interactive graph.

CSS Filter Generator

Visually create CSS filter effects like blur, contrast, sepia, etc.

CSS Flexbox Generator

Visually create CSS Flexbox layouts and configure item properties

CSS Glassmorphism Generator

An interactive glassmorphism CSS generator with live element previews

CSS Gradient Generator

Visually create linear and radial CSS gradients

CSS Grid Generator

Interactive CSS Grid Generator with visual previews

CSS Hover Animation Generator

Create interactive CSS hover effects with presets and controls

CSS Loader Generator

Generate pure CSS loading animations with customization

CSS Minifier

Minify CSS code for production

CSS Prettifier

Format and beautify CSS code

CSS Radio Button Generator

Design custom CSS radio buttons with styles and animations

CSS Scrollbar Generator

Visually style browser scrollbars (WebKit) with custom CSS

CSS Skew Generator

Visually create CSS skew (slant) transformations

CSS Sprite Generator

Combine images into optimized CSS sprites

CSS Stylesheet Generator

Visually build complete CSS rulesets for elements

CSS Text Shadow Generator

Generate CSS text shadow code

CSS to Tailwind Converter

Convert basic CSS rules to Tailwind utility classes

CSS Toggle Switch Generator

Browse and generate pure CSS toggle switch styles and animations

CSS Transform Generator

Visually create 2D/3D transforms (translate, rotate, scale, skew)

CSS Triangle Generator

Generate CSS code foor arrows and triangle shapes

CSS Typography Generator

Visually configure font styles, spacing, color, and generate CSS

.gitignore Generator

Generate .gitignore files using templates and AI suggestions

Go Struct to JSON Converter

Convert Go Struct to JSON

GraphQL Minifier

Minify GraphQL code for production

HTML Escape

Escape HTML special characters

HTML Iframe Generator

Generate HTML iframe code with customizable attributes

HTML Minifier

Minify HTML code for production

HTML Prettifier

Format and beautify HTML code

HTML Table Generator

Create HTML table code

HTML to BBCode Converter

Convert HTML to Bulletin Board code

HTML Unescape

Unescape HTML special characters

INI to JSON Converter

Convert INI to JSON

INI to XML Converter

Convert INI to XML

INI Validator

Check INI files for syntax errors

INI to YAML Converter

Convert INI to YAML

JavaScript Minifier

Minify JavaScript code for production

JavaScript Obfuscator

Obfuscate JavaScript code

JavaScript Prettifier

Format and beautify JavaScript code

JavaScript to JSON Converter

Convert JavaScript Objects to JSON

JSON Compare

Check the difference between two JSON files

JSON Escape

Escape JSON content

JSON Formatter

Format and validate JSON data

JSON Minifier

Minify JSON content for production

JSON Prettifier

Format and beautify JSON content

JSON Schema Validator

Validate JSON data against a JSON Schema

JSON to AVRO Converter

Convert JSON to Apache's AVRO format

JSON to Base64 Converter

Convert JSON to Base64 encoding

JSON to BSON Converter

Convert JSON code to binary JSON

JSON to C# Classes Converter

Convert JSON to C# Classes

JSON to Dart Converter

Convert JSON code to Dart

JSON to Go Struct Converter

Convert JSON code to Go Struct

JSON to INI Converter

Convert JSON code to INI format

JSON to JSDOC Converter

Convert JSON code to JSDOC format

JSON to JSON Schema Converter

Convert JSON to a JSON schema

JSON to Kotlin Class Converter

Convert JSON code to Kotlin Data Classes

JSON to Mongoose Schema Converter

Convert JSON to a Mongoose schema

JSON to NDJSON Converter

Convert JSON code to NDJSON format

JSON to Protobuf Converter

Convert JSON to Protobuf

JSON to Query String Converter

Convert JSON to a query string

JSON to Rust Structs Converter

Convert JSON code to Rust Serde Structs

JSON to Swift Structs Converter

Convert JSON code to Swift Structs

JSON to TOML Converter

Convert JSON to TOML

JSON to TypeScript Converter

Convert JSON to TypeScript

JSON to XML Converter

Convert JSON code to XML format

JSON to YAML Converter

Convert JSON code to YAML format

JSON to Zod Schema Converter

Convert JSON code to Zod schema

JSON Unescape

Unescape JSON content

Lua Minifier

Minify Lua code for production

Lua to JSON Converter

Convert Lua code to JSON

Lua to TypeScript Converter

Convert Lua code to TypeScript types and more

PHP Minifier

Minify PHP code for production

Protobuf to JSON Converter

Convert Protobuf to JSON

Protobuf to XML Converter

Convert Protobuf to XML

Protobuf to YAML Converter

Convert Protobuf to YAML

Pixels to REM Converter

Convert Pixels (PX) to REM

Python Minifier

Minify Python code for production

Query String to JSON Converter

Convert Query Strings to JSON format

Regex Generator (AI)

Generate regular expressions with the help of AI

REM to Pixels Converter

Convert REM to Pixels (PX)

SQL Prettifier

Format and beautify SQL queries

TOML to JSON Converter

Convert TOML to JSON

TOML to XML Converter

Convert TOML to XML

TOML to YAML Converter

Convert TOML to YAML

TOML Validator

Check TOML files for syntax errors

TypeScript Formatter

Format and beautify TypeScript files

TypeScript to JSON Schema Converter

Convert TypeScript types to JSON Schema

TypeScript to Lua Converter

Convert TypeScript code to Lua

XML Compare

Find the differences between two XML codebases

XML Formatter

Format and validate XML documents

XML to AVRO Converter

Convert XML code to AVRO format

XML to Base64 Converter

Convert XML code to Base64 encoding

XML to C# Class Converter

Convert XML code to C# Classes

XML to Go Struct Converter

Convert XML code to Go Struct

XML to JSON Converter

Convert XML code to JSON format

XML to Protobuf Converter

Convert XML to Protobuf

XML to TOML Converter

Convert XML code to TOML format

XML to TypeScript Converter

Convert XML code to TypeScript interfaces

XML to XSD Converter

Convert XML code to XSD format

XML to YAML Converter

Convert XML code to YAML format

XML Validator

Check XML documents for well-formedness errors

YAML Formatter

Format and beautify YAML files

YAML to Go Struct Converter

Convert YAML to Go Structs

YAML to INI Converter

Convert YAML code to INI format

YAML to JSON Converter

Convert YAML to JSON format

YAML to TOML Converter

Convert YAML code to TOML format

YAML to XML Converter

Convert YAML to XML format

YAML Validator

Check YAML files for syntax errors