@formio/js

中文文档
5.7.1发布于 2026/11/14MITTypeScriptESM + CJS近 30 天下载 21.5万

JavaScript powered Forms with JSON Form Builder

原始使用文档
文档目录14 节
  1. Official Documentation
  2. Examples and Demonstration
  3. Installation
  4. Form Building
  5. Form Builder Documentation
  6. Form Rendering
  7. JSFiddle Example
  8. Form Renderer Documentation
  9. Wizard Rendering
  10. Form Embedding
  11. Form Embedding Documentation
  12. JavaScript SDK
  13. JavaScript SDK Documentation.
  14. Full Developer API Documentation

JavaScript powered forms and SDK for Form.io

This library is a plain JavaScript form renderer and SDK for Form.io. This allows you to render the JSON schema forms produced by Form.io and render those within your application using plain JavaScript, as well as provides an interface SDK to communicate to the Form.io API's. The benefits of this library include.

  • Plain JavaScript implementation using ES6 and Modern practices (no jQuery, Angular, React, or any other framework dependency)
  • Renders a JSON schema as a webform and hooks up that form to the Form.io API's
  • Complete Form Builder which creates the JSON schema used to render the forms.
  • Nested components, layouts, Date/Time, Select, Input Masks, and many more included features
  • Full JavaScript API SDK library on top of Form.io

Official Documentation

For the latest documentation, release information, and guides, always refer to the official Form.io Help Documentation available here:

https://help.form.io

Examples and Demonstration

To find out more about this library as well as see a demonstration of what you can do with this library, go to the Examples and Demo site @ https://formio.github.io/formio.js

Installation

To install this SDK into your project, you can use the following command within your terminal.

npm install --save @formio/js

Form Building

This library has a very powerful JSON form builder, and can be used like the following.

<html>
  <head>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css"
    />
    <link rel="stylesheet" href="https://cdn.form.io/js/formio.full.min.css" />
    <script src="https://cdn.form.io/js/formio.full.min.js"></script>
  </head>
  <body>
    <div id="builder"></div>
    <script type="text/javascript">
      Formio.builder(document.getElementById('builder'), {}, {});
    </script>
  </body>
</html>

This will create a robust Form builder embedded right within your own application. See Our Demo Page for an example.

Form Builder Documentation

Go to the Form Builder Documentation for a full documentation on how the open source form builder works.

Form Rendering

The following is a simple example on how to render a form within your HTML application.

<html>
  <head>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css"
    />
    <script src="https://cdn.form.io/js/formio.embed.js"></script>
  </head>
  <body>
    <div id="formio"></div>
    <script type="text/javascript">
      Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/example');
    </script>
  </body>
</html>

This will render the following form within your application.

image

You can also render JSON directly instead of referencing the embed URL from Form.io.

Formio.createForm(document.getElementById('formio'), {
  components: [
    {
      type: 'textfield',
      key: 'firstName',
      label: 'First Name',
      placeholder: 'Enter your first name.',
      input: true,
    },
    {
      type: 'textfield',
      key: 'lastName',
      label: 'Last Name',
      placeholder: 'Enter your last name',
      input: true,
    },
    {
      type: 'button',
      action: 'submit',
      label: 'Submit',
      theme: 'primary',
    },
  ],
});

This will render the JSON schema of the form within your application.

JSFiddle Example

A great way to play around with this renderer is to use JSFiddle, which serves as a good sandbox environment. Here is an example that you can fork and make your own!

http://jsfiddle.net/travistidwell/z63jvwkp/

Form Renderer Documentation

For a more complete documentation of how to utilize this library within your application go to the Form Renderer documentation.

Wizard Rendering

This library can also be used to render a form wizard within your application using the same method as rendering a form. The determiniation on whether it should render as a wizard or not is based on the display property of the form schema being set to wizard.

<html>
  <head>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css"
    />
    <script src="https://cdn.form.io/js/formio.embed.js"></script>
  </head>
  <body>
    <div id="formio"></div>
    <script type="text/javascript">
      Formio.createForm(document.getElementById('formio'), 'https://examples.form.io/wizard');
    </script>
  </body>
</html>

Form Embedding

You can also use this library as a JavaScript embedding of the form using a single line of code. For example, to embed the https://examples.form.io/example form within your application you can simply use the following embed code.

<script src="https://cdn.form.io/js/formio.embed.min.js?src=https://examples.form.io/example&libs=true"></script>

For an example of how this looks and works, check out the following Form.io Inline Embedding

Form Embedding Documentation

For a more complete documentation of how to embed forms, go to the Form Embedding Documentation.

JavaScript SDK

In addition to having a Form Renderer within this application, you can also use this library as a JavaScript SDK in your application. For example, to load a Form, and then submit that form you could do the following within your JavaScript.

<html>
  <head>
    <script src="https://cdn.form.io/js/formio.min.js"></script>
    <script type="text/javascript">
      var formio = new Formio('https://examples.form.io/example');
      formio.loadForm().then(function (form) {
        // Log the form schema.
        console.log(form);

        formio
          .saveSubmission({
            data: {
              firstName: 'Joe',
              lastName: 'Smith',
              email: '[email protected]',
            },
          })
          .then(function (submission) {
            // Log the full submission object.
            console.log(submission);
          });
      });
    </script>
  </head>
</html>

You can also use this within an ES6 application as follows.

import { Formio } from '@formio/js/sdk';
let formio = new Formio('https://examples.form.io/example');
formio.loadForm((form) => {
  console.log(form);
  formio
    .saveSubmission({
      data: {
        firstName: 'Joe',
        lastName: 'Smith',
        email: '[email protected]',
      },
    })
    .then((submission) => {
      console.log(submission);
    });
});

JavaScript SDK Documentation.

For more complete documentation over the JavaScript SDK, please take a look at the JavaScript SDK Documentation.

Full Developer API Documentation

To view the full SDK Documentation, go to Developer SDK Documentation

版本与发布记录

@formio/js 共发布 703 个版本,首次发布于 2023/06/08;过去 12 个月发布了 30 个版本。

版本发布日期距今
5.7.1latest2026/11/142 天前
5.7.02026/10/101 个月前
5.7.0-api912.22026/10/021 个月前
5.6.12026/09/231 个月前
5.6.02026/09/171 个月前
5.5.22026/08/272 个月前

其他发布通道:dev.tt → 5.0.0-rc.59,5_1_x → 5.1.2-rc.6,5_0_x → 5.0.3-rc.7,dev → 5.2.1-dev.6247.62839b6,5_2_x → 5.2.4-rc.0,5_3_x → 5.3.0-rc.4。

关于 @formio/js 的常见问题

@formio/js 是什么?

JavaScript powered Forms with JSON Form Builder

如何安装 @formio/js?

在项目目录运行 npm install @formio/js,或使用 pnpm add / yarn add / bun add。

@formio/js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@formio/js 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@formio/js 可以商用吗?

@formio/js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@formio/js 的下载量有多少?

根据 npm 官方下载统计,@formio/js 在 2026/10/16 – 2026/11/14 这 30 天内被下载 215,027 次,日均约 7,168 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@formio/js 还在维护吗?

最新版本 5.7.1 发布于 2026/11/14(2 天前);至今共发布 703 个版本,其中过去 12 个月发布了 30 个;首次发布于 2023/06/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。