# @multiformats/multiaddr

> The JavaScript implementation of the Multiaddr spec

Latest version **13.0.3** (published 2026-05-12) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install @multiformats/multiaddr
pnpm add @multiformats/multiaddr
yarn add @multiformats/multiaddr
bun add @multiformats/multiaddr
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 13.0.3 |
| Published | 2026-05-12 |
| First published | 2022-01-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 4 |
| Unpacked size | 309.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 108 |
| Maintainers | daviddias, vmx, mikeal, hugomrdias, alanshaw, achingbrain, vascosantos, rvagg, lidel, npm-service-account-multiformats |
| Keywords | binary, multiaddr, string |

## Links

- npm: https://www.npmjs.com/package/@multiformats/multiaddr
- Repository: https://github.com/multiformats/js-multiaddr
- Homepage: https://github.com/multiformats/js-multiaddr#readme
- Issues: https://github.com/multiformats/js-multiaddr/issues
- npm.io page: https://npm.io/package/@multiformats/multiaddr

## Dependencies (4)

- [uint8arrays](https://npm.io/package/uint8arrays.md) ^6.1.1
- [multiformats](https://npm.io/package/multiformats.md) ^14.0.0
- [uint8-varint](https://npm.io/package/uint8-varint.md) ^3.0.0
- [@chainsafe/is-ip](https://npm.io/package/@chainsafe/is-ip.md) ^2.0.1

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 13.0.3 (latest) — 2026-05-12
- 13.0.2 — 2026-05-12
- 13.0.1 — 2025-09-04
- 13.0.0 — 2025-09-02
- 12.5.1 — 2025-06-25
- 12.5.0 — 2025-06-18
- 12.4.4 — 2025-06-16
- 12.4.3 — 2025-06-16
- 12.4.2 — 2025-06-16
- 12.4.1 — 2025-05-30
- 12.4.0 — 2025-02-20
- 12.3.5 — 2025-02-05
- 12.3.4 — 2024-12-03
- 12.3.3 — 2024-11-21
- 12.3.2 — 2024-11-21
- … 70 more at https://npm.io/package/@multiformats/multiaddr/versions

## README

# @multiformats/multiaddr

[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io)
[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiaddr.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiaddr)
[![CI](https://img.shields.io/github/actions/workflow/status/multiformats/js-multiaddr/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/multiformats/js-multiaddr/actions/workflows/js-test-and-release.yml?query=branch%3Amain)

> The JavaScript implementation of the Multiaddr spec

# About

<!--

!IMPORTANT!

Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.

To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts

To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.

-->

A standard way to represent addresses that

- support any standard network protocol
- have a binary packed format
- have a nice string representation
- encapsulate well

## Example

```TypeScript
import { multiaddr } from '@multiformats/multiaddr'

const addr = multiaddr('/ip4/127.0.0.1/udp/1234')
// Multiaddr(/ip4/127.0.0.1/udp/1234)

addr.bytes
// <Uint8Array 04 7f 00 00 01 11 04 d2>

addr.toString()
// '/ip4/127.0.0.1/udp/1234'

addr.getComponents()
// [
//   { code: 4, name: 'ip4', value: '127.0.0.1' },
//   { code: 273, name: 'udp', value: '1234' }
// ]

addr.encapsulate('/sctp/5678')
// Multiaddr(/ip4/127.0.0.1/udp/1234/sctp/5678)
```

## Example - Adding custom protocols

To add application-specific or experimental protocols, add a protocol codec
to the protocol registry:

```ts
import { registry, V, multiaddr } from '@multiformats/multiaddr'
import type { ProtocolCodec } from '@multiformats/multiaddr'

const maWithCustomTuple = '/custom-protocol/hello'

// throws UnknownProtocolError
multiaddr(maWithCustomTuple)

const protocol: ProtocolCodec = {
  code: 2059,
  name: 'custom-protocol',
  size: V
  // V means variable length, can also be 0, a positive integer (e.g. a fixed
  // length or omitted
}

registry.addProtocol(protocol)

// does not throw UnknownProtocolError
multiaddr(maWithCustomTuple)

// protocols can also be removed
registry.removeProtocol(protocol.code)
```

# Install

```console
$ npm i @multiformats/multiaddr
```

## Browser `<script>` tag

Loading this module through a script tag will make its exports available as `MultiformatsMultiaddr` in the global namespace.

```html
<script src="https://unpkg.com/@multiformats/multiaddr/dist/index.min.js"></script>
```

# API Docs

- <https://multiformats.github.io/js-multiaddr>

# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](https://github.com/multiformats/js-multiaddr/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/multiformats/js-multiaddr/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

# Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

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