# @multiformats/multiaddr-to-uri

> Convert a Multiaddr to a URI

Latest version **12.0.0** (published 2025-09-03) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 12.0.0 |
| Published | 2025-09-03 |
| First published | 2022-01-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 221.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 6 |
| Author | Alan Shaw |
| Maintainers | daviddias, vmx, mikeal, hugomrdias, alanshaw, achingbrain, vascosantos, rvagg, lidel, npm-service-account-multiformats |
| Keywords | URL, multiaddr, toString |

## Links

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

## Dependencies (1)

- [@multiformats/multiaddr](https://npm.io/package/@multiformats/multiaddr.md) ^13.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 12.0.0 (latest) — 2025-09-03
- 11.0.2 — 2025-06-27
- 11.0.1 — 2025-06-27
- 11.0.0 — 2024-11-08
- 10.1.2 — 2024-10-28
- 10.1.1 — 2024-10-26
- 10.1.0 — 2024-06-06
- 10.0.1 — 2024-02-05
- 10.0.0 — 2024-02-05
- 9.0.8 — 2024-02-05
- 9.0.7 — 2023-05-19
- 9.0.6 — 2023-05-19
- 9.0.5 — 2023-05-19
- 9.0.4 — 2023-03-20
- 9.0.3 — 2023-03-17
- … 4 more at https://npm.io/package/@multiformats/multiaddr-to-uri/versions

## README

# @multiformats/multiaddr-to-uri

[![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-to-uri.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiaddr-to-uri)
[![CI](https://img.shields.io/github/actions/workflow/status/multiformats/js-multiaddr-to-uri/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/multiformats/js-multiaddr-to-uri/actions/workflows/js-test-and-release.yml?query=branch%3Amain)

> Convert a Multiaddr to a URI

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

-->

This module allows easy conversion of Multiaddrs to string URIs.

## Example - Converting multiaddrs to string URIs

```js
import { multiaddrToUri } from '@multiformats/multiaddr-to-uri'

console.log(multiaddrToUri('/dnsaddr/protocol.ai/https'))
// -> https://protocol.ai

console.log(multiaddrToUri('/ip4/127.0.0.1/tcp/8080'))
// -> http://127.0.0.1:8080

console.log(multiaddrToUri('/ip4/127.0.0.1/tcp/8080', { assumeHttp: false }))
// -> tcp://127.0.0.1:8080
```

Note:

- When `/tcp` is the last (terminating) protocol HTTP is assumed by default (implicit `assumeHttp: true`)
  - this means produced URIs will start with `http://` instead of `tcp://`
  - passing `{ assumeHttp: false }` disables this behavior
- Might be lossy - e.g. a DNSv6 multiaddr
- Can throw if the passed multiaddr:
  - is not a valid multiaddr
  - is not supported as a URI e.g. circuit

# Install

```console
$ npm i @multiformats/multiaddr-to-uri
```

## Browser `<script>` tag

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

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

# API Docs

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

# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](https://github.com/multiformats/js-multiaddr-to-uri/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/multiformats/js-multiaddr-to-uri/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-to-uri · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
