JavaScript implementation of multiaddr
JavaScript Groovy
Clone or download


Coverage Status Travis CI Circle CI Dependency Status js-standard-style

JavaScript implementation of multiaddr.

Lead Maintainer

Victor Bjelkholm

Table of Contents


What is multiaddr?

A standard way to represent addresses that

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


npm i multiaddr



const multiaddr = require('multiaddr')

Browser: Browserify, Webpack, other bundlers

The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process.

const multiaddr = require('multiaddr')

Browser: <script> Tag

Loading this module through a script tag will make the Multiaddr obj available in the global namespace.

<script src=""></script>
<!-- OR -->
<script src=""></script>

NOTE: You will need access to the Node.js Buffer API. If you are running in the browser, you can access it with multiaddr.Buffer or you can install feross/buffer.


$ node

> const multiaddr = require('multiaddr')

> const addr = multiaddr("/ip4/")
<Multiaddr /ip4/>

> addr.buffer
<Buffer 04 7f 00 00 01 11 04 d2>

> addr.toString()

> addr.protos()
  {code: 4, name: 'ip4', size: 32},
  {code: 17, name: 'udp', size: 16}

// gives you an object that is friendly with what Node.js core modules expect for addresses
> addr.nodeAddress()
  family: "4",
  port: 1234,
  address: ""

> addr.encapsulate('/sctp/5678')
<Multiaddr /ip4/>



Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.


MIT © 2016 Protocol Labs Inc.