# @foxglove/rosmsg

> Parser for ROS and ROS 2 .msg definitions

Latest version **5.0.5** (published 2025-10-13) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 5.0.5 |
| Published | 2025-10-13 |
| First published | 2021-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 14 |
| Dependencies | 2 |
| Unpacked size | 216.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 30 |
| Author | Foxglove Technologies Inc |
| Maintainers | foxglovebot, amacneil |
| Keywords | ros, ros1, ros2, message, definition, msg, srv, msgdef, parser, grammar |

## Links

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

## Dependencies (2)

- [md5-typescript](https://npm.io/package/md5-typescript.md) ^1.0.5
- [@foxglove/message-definition](https://npm.io/package/@foxglove/message-definition.md) 0.5.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

- 5.0.5 (latest) — 2025-10-13
- 5.0.4 — 2024-04-24
- 5.0.3 — 2024-01-22
- 5.0.2 — 2023-11-13
- 5.0.1 — 2023-10-25
- 4.2.2 — 2023-04-21
- 4.2.1 — 2023-03-22
- 4.2.0 — 2023-03-09
- 4.1.0 — 2023-03-07
- 4.0.0 — 2023-02-28
- 3.1.0 — 2022-09-09
- 3.0.0 — 2021-10-30
- 2.0.0 — 2021-08-19
- 1.0.2 — 2021-08-11
- 1.0.1 — 2021-08-05
- … 6 more at https://npm.io/package/@foxglove/rosmsg/versions

## README

# @foxglove/rosmsg

> _ROS1 and ROS2 message definition parser_

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

## Introduction

[The Robot Operating System (ROS)](https://www.ros.org/) defines a simplified message description language for describing data types. This library parses those message definitions and can round trip them back into a canonical string format suitable for checksum generation. The parsed definitions are useful for serialization or deserialization when paired with other libraries.

This library supports both [ROS1](http://wiki.ros.org/msg) and [ROS 2](https://docs.ros.org/en/galactic/Concepts/About-ROS-Interfaces.html) message definitions.

## ROS 1 Definition Usage

```Typescript
import { parse, stringify } from "@foxglove/rosmsg";

const definitionStr = `# geometry_msgs/Pose
geometry_msgs/Point position
geometry_msgs/Quaternion orientation

===
MSG: geometry_msgs/Point
float64 x
float64 y
float64 z

===
MSG: geometry_msgs/Quaternion
float64 x
float64 y
float64 z
float64 w`;

const messageDefinition = parse(definitionStr);

// print the parsed message definition structure
console.log(JSON.stringify(messageDefinition, null, 2));
```

Prints:

```JSON
[
  {
    "definitions": [
      {
        "type": "geometry_msgs/Point",
        "isArray": false,
        "name": "position",
        "isComplex": true
      },
      {
        "type": "geometry_msgs/Quaternion",
        "isArray": false,
        "name": "orientation",
        "isComplex": true
      }
    ]
  },
  {
    "name": "geometry_msgs/Point",
    "definitions": [
      {
        "type": "float64",
        "isArray": false,
        "name": "x",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "y",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "z",
        "isComplex": false
      }
    ]
  },
  {
    "name": "geometry_msgs/Quaternion",
    "definitions": [
      {
        "type": "float64",
        "isArray": false,
        "name": "x",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "y",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "z",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "w",
        "isComplex": false
      }
    ]
  }
]
```

## ROS 2 Definition Usage

```Typescript
import { parse, stringify } from "@foxglove/rosmsg";

const definitionStr = `# geometry_msgs/msg/Pose
geometry_msgs/msg/Point position
geometry_msgs/msg/Quaternion orientation

===
MSG: geometry_msgs/msg/Point
float64 x
float64 y
float64 z

===
MSG: geometry_msgs/msg/Quaternion
float64 x
float64 y
float64 z
float64 w`;

const messageDefinition = parse(definitionStr, {ros2: true});

// stringify(messageDefinition) will return a canonical string, similar to
// _definitionStr_
// print the parsed message definition structure
console.log(JSON.stringify(messageDefinition, null, 2));
```

Prints:

```JSON
[
  {
    "definitions": [
      {
        "type": "geometry_msgs/msg/Point",
        "isArray": false,
        "name": "position",
        "isComplex": true
      },
      {
        "type": "geometry_msgs/msg/Quaternion",
        "isArray": false,
        "name": "orientation",
        "isComplex": true
      }
    ]
  },
  {
    "name": "geometry_msgs/msg/Point",
    "definitions": [
      {
        "type": "float64",
        "isArray": false,
        "name": "x",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "y",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "z",
        "isComplex": false
      }
    ]
  },
  {
    "name": "geometry_msgs/msg/Quaternion",
    "definitions": [
      {
        "type": "float64",
        "isArray": false,
        "name": "x",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "y",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "z",
        "isComplex": false
      },
      {
        "type": "float64",
        "isArray": false,
        "name": "w",
        "isComplex": false
      }
    ]
  }
]
```

## ROS 2 IDL Support

See (`@foxglove/ros2idl-parser`)[https://github.com/foxglove/omgidl/packages/ros2idl-parser] for our implementation of `ros2idl` schema support.

## License

@foxglove/rosmsg 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

## 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 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
