# @foxglove/rosmsg-serialization

> ROS 1 message serialization, for reading and writing bags and network messages

Latest version **2.1.3** (published 2026-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @foxglove/rosmsg-serialization
pnpm add @foxglove/rosmsg-serialization
yarn add @foxglove/rosmsg-serialization
bun add @foxglove/rosmsg-serialization
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.3 |
| Published | 2026-10-30 |
| First published | 2021-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 14 |
| Dependencies | 1 |
| Unpacked size | 410.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 30 |
| Author | Foxglove Technologies Inc |
| Maintainers | foxglovebot, amacneil |
| Keywords | ros, ros1, robot, operating, system, serialization, protocol, rosbag, serde |

## Links

- npm: https://www.npmjs.com/package/@foxglove/rosmsg-serialization
- Repository: https://github.com/foxglove/ros-typescript
- npm.io page: https://npm.io/package/@foxglove/rosmsg-serialization

## Dependencies (1)

- [@foxglove/message-definition](https://npm.io/package/@foxglove/message-definition.md) 0.5.0

## Recent versions

- 2.1.3 (latest) — 2026-10-30
- 2.1.2 — 2026-07-01
- 2.1.1 — 2026-05-20
- 2.1.0 — 2026-05-07
- 2.0.4 — 2025-10-13
- 2.0.3 — 2024-01-22
- 2.0.2 — 2023-09-05
- 2.0.1 — 2023-03-22
- 2.0.0 — 2023-02-28
- 1.5.3 — 2022-10-05
- 1.5.2 — 2022-09-12
- 1.5.1 — 2022-09-12
- 1.5.0 — 2022-08-08
- 1.4.0 — 2022-08-08
- 1.3.0 — 2021-12-16
- … 12 more at https://npm.io/package/@foxglove/rosmsg-serialization/versions

## README

# @foxglove/rosmsg-serialization

> _ROS1 (Robot Operating System) message serialization, for reading and writing bags and network messages_

[![npm version](https://img.shields.io/npm/v/@foxglove/rosmsg-serialization.svg?style=flat)](https://www.npmjs.com/package/@foxglove/rosmsg-serialization)

## MessageReader

Message reader deserializes ROS messages into plain objects. The messages are fully deserialized.

```typescript
import { MessageReader } from "@foxglove/rosmsg-serialization";

// message definition comes from `parse()` in @foxglove/rosmsg
const reader = new MessageReader(messageDefinition);

// deserialize a buffer into an object
const message = reader.readMessage([0x00, 0x00, ...]);

// access message fields
message.header.stamp;
```

## LazyMessage

Lazy messages provide on-demand access and deserialization to fields of a serialized ROS message. Creating
a lazy message from a buffer performs no de-serialization during creation. Only accessed fields are
deserialized; the deserialization occurs at access time.

```Typescript
import { LazyMessageReader } from "@foxglove/rosmsg-serialization";

// message definition comes from `parse()` in @foxglove/rosmsg
const reader = new LazyMessageReader(messageDefinition);

// build a new lazy message instance for our serialized message from the Uint8Array
// Note: since deserialization is lazy - avoid-reusing the array you provide for other messages
const message = reader.readMessage([0x00, 0x00, ...]);

// access message fields
message.header.stamp;
```

## MessageWriter

Convert an object, array, or primitive value into binary data using ROS message serialization.

```Typescript
import { MessageWriter } from "@foxglove/rosmsg-serialization";

// message definition comes from `parse()` in @foxglove/rosmsg
const writer = new MessageWriter(pointStampedMessageDefinition);

// serialize the passed in object to a Uint8Array as a geometry_msgs/PointStamped message
const uint8Array = writer.writeMessage({
  header: {
    seq: 0,
    stamp: { sec: 0, nsec: 0 },
    frame_id: ""
  },
  x: 1,
  y: 0,
  z: 0
});
```

### Test

`yarn test`

## License

@foxglove/rosmsg-serialization is licensed under the [MIT License](https://opensource.org/licenses/MIT).

## Releasing

1. Run `yarn version --[major|minor|patch]` to bump version
2. Run `git push && git push --tags` to push new tag
3. GitHub Actions will take care of the rest

## Benchmarks

The `bench` folder contains benchmarks. Run with:

```
yarn bench
yarn bench:benny
```

To run benchmarks in web:

```
yarn bench:web
```

## Stay in touch

Join our [Discord community](https://foxglove.dev/chat) to ask questions, share feedback, and stay up to date on what our team is working on.

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