# @foxglove/message-definition

> Defines common types for message definition schemas (ROS .msg, Protobuf, FlatBuffers, IDL, PX4 ULog, JSON Schema, etc)

Latest version **0.5.0** (published 2025-10-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @foxglove/message-definition
pnpm add @foxglove/message-definition
yarn add @foxglove/message-definition
bun add @foxglove/message-definition
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2025-10-09 |
| First published | 2023-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 31.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 3 |
| Author | Foxglove Technologies Inc |
| Maintainers | foxglovebot, amacneil |
| Keywords | schema, message, definition, serialization, deserialization, msg, msgdef, idl, protobuf, parser, grammar |

## Links

- npm: https://www.npmjs.com/package/@foxglove/message-definition
- Repository: https://github.com/foxglove/message-definition
- Issues: https://github.com/foxglove/message-definition/issues
- npm.io page: https://npm.io/package/@foxglove/message-definition

## 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

- 0.5.0 (latest) — 2025-10-09
- 0.4.0 — 2024-11-07
- 0.3.1 — 2023-10-10
- 0.3.0 — 2023-07-26
- 0.2.0 — 2023-02-28

## README

# @foxglove/message-definition

[![@foxglove/message-definition on npm](https://shields.io/npm/v/@foxglove/message-definition)](https://www.npmjs.com/package/@foxglove/message-definition)

> Defines common TypeScript types for message definition schemas (ROS .msg, Protobuf, FlatBuffers, IDL, PX4 ULog, JSON Schema, etc).

## Why is this useful?

Several interface definition languages exist today for describing the structure of messages. These languages are often used to generate code for serialization and deserialization of messages. This package defines a common representation in TypeScript for interface definitions, sometimes referred to as message definitions, so they can be reasoned about in a generic way. A concrete example of this is in [Foxglove](https://foxglove.dev/product), which supports many different message serializations but provides common functionality across all of them such as [Message Path Syntax](https://docs.foxglove.dev/docs/visualization/message-path-syntax/) and structured message display.

## Examples

Here is a an example of a ROS 2 message definition (`.msg` file) and its corresponding TypeScript representation:

`UserAccount.msg`:

```
string username
Account account
============
MSG: custom_type/Account
string name
uint16 id
```

`UserAccount.ts`:

```typescript
[
  {
    definitions: [
      { type: "string", name: "username" },
      { type: "custom_type/Account", name: "account", isComplex: true },
    ],
  },
  {
    name: "custom_type/Account",
    definitions: [
      { type: "string", name: "name" },
      { type: "uint16", name: "id" },
    ],
  },
];
```

Note that this package only provides type definitions, not any functionality for parsing or generating message definitions. For that, see [foxglove/rosmsg](https://github.com/foxglove/rosmsg) or other packages that depend on this one.

## License

@foxglove/message-definition is licensed under [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/message-definition · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
