HTML formenctype Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The formenctype attribute sets how form data is encoded when a specific submit control is used. It overrides the form’s enctype for that click only. Use it on a <button> that submits a form, or on <input type="submit"> / type="image".

Typical case: the form defaults to urlencoded text, but one button uploads a file and needs multipart/form-data. Pair with formmethod or formaction when that button also needs a different method or URL.

Baseline · Widely available.

Not deprecated and not experimental. Stable across modern browsers since about July 2015.

Files need multipart.

If the submission includes <input type="file">, use multipart/form-data (via enctype or formenctype). Urlencoded encoding cannot send file contents correctly.

HTML Syntax

syntax.html
<button type="submit" formenctype=" encoding">

encoding is one of the three values listed below.

Attribute Values

Same three encodings as enctype:

ValueDescriptionTry it
application/x-www-form-urlencodedDefault. Name/value pairs percent-encoded in the body (or query for GET)Try it
multipart/form-dataRequired for file uploads; uses multipart MIME partsTry it
text/plainPlain text pairs — mainly for debugging, not production APIsTry it

Live Preview

Change the override encoding on the second button, then submit. Submission is intercepted so you can see the effective enctype.

Form default enctype is urlencoded. The override button uses formenctype.

Demo form

formenctype="multipart/form-data"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Explicit Urlencoded Submit

Force the default encoding on one button even if the form sets something else.

HTML
<form action="/contact" method="post" enctype="text/plain">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email">

  <button type="submit">Send as text/plain</button>
  <button
    type="submit"
    formenctype="application/x-www-form-urlencoded">
    Send as urlencoded
  </button>
</form>
Try It Yourself

How It Works

  1. Form default. enctype="text/plain" applies when the first button is used.
  2. Override on one button. The second sets formenctype to urlencoded.
  3. Same fields. Only the encoding changes for that click.
  4. Urlencoded is what most servers expect for ordinary text fields.

Example 2 — Multipart for File Upload

Use multipart encoding when a button submits a file field.

HTML
<form action="/profile" method="post">
  <label for="bio">Bio:</label>
  <input type="text" id="bio" name="bio">

  <label for="avatar">Avatar:</label>
  <input type="file" id="avatar" name="avatar" accept="image/*">

  <button type="submit">Save text only</button>
  <button
    type="submit"
    formenctype="multipart/form-data">
    Upload with photo
  </button>
</form>
Try It Yourself

How It Works

  1. Default form uses urlencoded — fine for text-only saves.
  2. File field present. Uploading needs multipart/form-data.
  3. Upload button sets formenctype so that click encodes correctly.
  4. Often better: set enctype="multipart/form-data" on the form if every submit may include files.

Example 3 — text/plain for Debugging

Send a readable plain-text body — useful while learning, not for real APIs.

HTML
<form action="/debug" method="post">
  <label for="note">Note:</label>
  <input type="text" id="note" name="note" value="hello">

  <button type="submit">Normal submit</button>
  <button type="submit" formenctype="text/plain">Debug as text/plain</button>
</form>
Try It Yourself

How It Works

  1. Normal submit uses the form’s default urlencoded encoding.
  2. Debug button sets formenctype="text/plain".
  3. Easier to read in network tools — spaces and simple name=value lines.
  4. Not for production. Prefer urlencoded or multipart for real endpoints.

Edge Cases & Pitfalls

Most bugs are missing multipart for files or using the wrong button type.

files

File inputs need multipart

Urlencoded and text/plain will not upload binary file data correctly. Use multipart/form-data.

owner

Needs a form owner

Nest the control in a form or set the form attribute. Alone, formenctype does nothing.

type

Only on submit controls

type="button" and type="reset" ignore formenctype.

script

IDL name is formEnctype

In JavaScript, read or set element.formEnctype (camelCase).

family

Sibling overrides exist

Also see formaction, formmethod, formnovalidate, and formtarget.

Browser Support

formenctype is an HTML attribute for submit controls in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

formenctype

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support overriding form encoding from a submit control.

97% Global support (approx.)
Google Chrome 9+
Full support
Mozilla Firefox 4+
Full support
Apple Safari 5.1+
Full support
Microsoft Edge 12+
Full support
Opera 10.6+
Full support
Samsung Internet Modern
Full support
Internet Explorer 10+
Supported
formenctype Widely supported

Bottom line: Safe to use for per-button encoding overrides. For forms that always upload files, set enctype on the form itself.

Key Takeaways

  • Role: override the form’s enctype for one submit control.
  • Values: urlencoded, multipart/form-data, or text/plain.
  • Files: always use multipart when uploading with type="file".
  • Elements: submitting <button>, input type="submit", type="image".

One line: formenctype lets one submit button pick a different encoding without changing the whole form.

Frequently Asked Questions

On a submit button or input type=submit (or image), formenctype sets how form data is encoded for that submission. It overrides the enctype attribute on the owning form.
Three values: application/x-www-form-urlencoded (default), multipart/form-data (required for file uploads), and text/plain (mostly for debugging).
Whenever the form includes input type=file. Without multipart encoding, file contents are not sent correctly.
button (when it submits a form) and input with type=submit or type=image. It has no effect on type=button or type=reset.
enctype is set on the form and is the default encoding. formenctype is set on a specific submit control and overrides enctype when that control is used.
It is Baseline widely available (since about July 2015) in modern Chrome, Firefox, Safari, and Edge.

Next: formmethod

Override GET or POST from a specific submit button.

formmethod tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful