# @momsfriendlydevco/marshal

> Marshaling serializer for modern JavaScript primitives + circular objects

Latest version **2.2.0** (published 2025-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @momsfriendlydevco/marshal
pnpm add @momsfriendlydevco/marshal
yarn add @momsfriendlydevco/marshal
bun add @momsfriendlydevco/marshal
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2025-09-16 |
| First published | 2018-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=16.14.0 |
| Dependencies | 2 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matt Carter |
| Maintainers | hash-bang, 1watt, eekthecat, mr-yellow, connorf25 |
| Keywords | marshal, serialize, serializer, parser, lexer |

## Links

- npm: https://www.npmjs.com/package/@momsfriendlydevco/marshal
- Repository: https://github.com/MomsFriendlyDevCo/marshal
- Homepage: https://github.com/MomsFriendlyDevCo/marshal#readme
- Issues: https://github.com/MomsFriendlyDevCo/marshal/issues
- npm.io page: https://npm.io/package/@momsfriendlydevco/marshal

## Dependencies (2)

- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.21
- [lodash-keyarrange](https://npm.io/package/lodash-keyarrange.md) ^2.0.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2025-09-16
- 2.1.4 — 2025-02-26
- 2.1.3 — 2025-02-20
- 2.1.2 — 2025-02-17
- 2.1.1 — 2025-02-13
- 2.1.0 — 2025-02-13
- 2.0.0 — 2023-05-09
- 1.1.1 — 2022-01-14
- 1.1.0 — 2019-06-17
- 1.0.1 — 2018-10-22
- 1.0.0 — 2018-09-24
- 0.0.0 — 2018-09-24

## README

@momsfriendlydevco/marshal
==========================
A simple marshaling serializer for modern JavaScript primitives.

**Features**:

* Will attempt to serialize all known JS primitive types (dates, NaN, sets, undefined etc.)
* Can serialize / deserialize circular structures
* Simple serialize / deserialize usage
* Extremely fast - uses its own traversal system rather than a 3rd party NPM library
* Low dependency count - only Lodash is needed


```javascript
var marshal = require('@momsfriendlydevco/marshal');

var serializedString = marshal.serialize({... some complex object ...});

var deserializedObject = marshal.deserialize(serializedString);
```

See the [testkit](./test) for more complex examples.


API
===

marshal.serialize(Object, [Settings])
-------------------------------------
The object or primitive to transform into a string.
Settings are inherited from the main `marshal.settings` structure or overridden by any settings passed in here.


marshal.deserialize(String, [Settings])
---------------------------------------
Transform a serialized string back into a native JS object.
Settings are inherited from the main `marshal.settings` structure or overridden by any settings passed in here.


marshal.settings
----------------
The objects to use when operating.

| Option        | Type      | Default                  | Description                                                                                                            |
|---------------|-----------|--------------------------|------------------------------------------------------------------------------------------------------------------------|
| `clone`       | `Boolean` | `false`                  | Clone the input to the serialize / deserialize functions before operating. Adds overhead but will not mutate the input |
| `circular`    | `Boolean` | `true`                   | Detect and manage circular references, if you know the input / output object cannot be circular there is a speed bonus to disabling this |
| `symetric`    | `Boolean` | `false`                  | Encode objects symetrically - i.e. reorder keys so that they can be consistantly hashed                                |
| `depth`       | `Number`  | `0`                      | The maximum depth to traverse into when operating. If zero this is infinite                                            |
| `modules`     | `Array`   | [All modules](./modules) | Which modules to use when operating (see notes below)                                                                  |
| `stringify`   | `Boolean` | `true`                   | Whether to transform the mutated object in `marshal.serialize()` into a string                                         |
| `destringify` | `Boolean` | `true`                   | Assume that input to `marshal.deserialize()` is a string which needs transforming first                                |


**NOTES:**

* Modules can be specified as simple strings (e.g. 'date') which assumes they are built in modules [provided with the NPM](./modules), if this is a path that path is automatically included. If this is an object it is assumed to be an already compatible module
* All modules must expose a `id`, `test`, `serialize` and `deserialize` properties
* All module functions are called as `(v:Any, path:Array<String>)`

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