# formobj

> Turns form values into json and back into form values

Latest version **5.1.0** (published 2019-07-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install formobj
pnpm add formobj
yarn add formobj
bun add formobj
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2019-07-02 |
| First published | 2016-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 16.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | First+Third |
| Maintainers | alaguna, aleperez92, dawnerd, ecwillis, jga, orthagonal1 |
| Keywords | browser, form, json |

## Links

- npm: https://www.npmjs.com/package/formobj
- Repository: https://github.com/firstandthird/formobj
- Homepage: https://github.com/firstandthird/formobj#readme
- Issues: https://github.com/firstandthird/formobj/issues
- npm.io page: https://npm.io/package/formobj

## Dependencies (1)

- [domassist](https://npm.io/package/domassist.md) ^2.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 5.1.0 (latest) — 2019-07-02
- 5.0.0 — 2019-02-22
- 4.0.1 — 2018-02-09
- 4.0.0 — 2017-03-02
- 3.0.0 — 2017-02-08
- 2.0.0 — 2016-12-16
- 1.2.0 — 2016-12-03
- 1.1.0 — 2016-12-03

## README

# formobj ![npm](https://img.shields.io/npm/v/formobj.svg) [![Build Status](https://travis-ci.org/firstandthird/formobj.svg?branch=master)](https://travis-ci.org/firstandthird/formobj)

Converts form elements with a `name` attribute to JSON.

## Installation

```sh
npm install formobj
```

## Usage

```html
<form id="SuperAmazingForm">
  <input type="text" name="username" value="superdude">
  <select name="capecolors" multiple>
    <option value="blue" selected>Blue</option>
    <option value="white">White</option>
    <option value="red" selected>Red</option>
  </select>
  <input type="checkbox" checked name="powerful">
  <input type="checkbox" name="smart">
</form>
```

```js
import FormObj from 'formobj';

const form = new FormObj(document.getElementById('SuperAmazingForm'));

const data = form.getJSON();
```

## Outputs

```json
{
    "username": "superdude",
    "capecolors": ["blue", "red"],
    "powerful": true,
    "smart": false
}
```

**Note:** Items that share the same name will become an array of values.

---
_Source: https://npm.io/package/formobj · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
