# @cosmjs/encoding

> Encoding helpers for blockchain projects

Latest version **0.39.0** (published 2026-05-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @cosmjs/encoding
pnpm add @cosmjs/encoding
yarn add @cosmjs/encoding
bun add @cosmjs/encoding
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.39.0 |
| Published | 2026-05-04 |
| First published | 2020-06-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 700 |
| Maintainers | webmaster128, kiki-skip |

## Links

- npm: https://www.npmjs.com/package/@cosmjs/encoding
- Repository: https://github.com/cosmos/cosmjs/tree/main/packages/encoding
- npm.io page: https://npm.io/package/@cosmjs/encoding

## Dependencies (3)

- [base64-js](https://npm.io/package/base64-js.md) ^1.3.0
- [@scure/base](https://npm.io/package/@scure/base.md) ^2.0.0
- [readonly-date-esm](https://npm.io/package/readonly-date-esm.md) ^2.0.0

## Recent versions

- 0.39.0 (latest) — 2026-05-04
- 0.37.1 (backports-unsorted) — 2025-12-31
- 0.38.0-rc.1 (next) — 2025-12-24
- 0.38.1 — 2025-12-31
- 0.38.0 — 2025-12-30
- 0.38.0-rc.0 — 2025-12-24
- 0.37.0 — 2025-10-29
- 0.35.2 — 2025-10-29
- 0.37.0-rc.1 — 2025-10-24
- 0.36.2-0 — 2025-10-24
- 0.36.2 — 2025-10-24
- 0.35.1 — 2025-10-22
- 0.34.1 — 2025-10-22
- 0.37.0-rc.0 — 2025-10-17
- 0.36.1 — 2025-10-02
- … 112 more at https://npm.io/package/@cosmjs/encoding/versions

## README

# @cosmjs/encoding

![typescript](https://img.shields.io/npm/types/@cosmjs/encoding.svg)
[![npm version](https://img.shields.io/npm/v/@cosmjs/encoding.svg)](https://www.npmjs.com/package/@cosmjs/encoding)
[![license](https://img.shields.io/npm/l/@cosmjs/encoding.svg)](https://github.com/cosmos/cosmjs/blob/v0.35.0/LICENSE)
![minimum node version](https://img.shields.io/node/v/@cosmjs/encoding.svg)
![minified size](https://img.shields.io/bundlephobia/min/@cosmjs/encoding.svg)
![monthly downloads](https://img.shields.io/npm/dm/@cosmjs/encoding.svg)

This package is an extension to the JavaScript standard library that is not
bound to blockchain products. It provides basic hex/base64/ascii encoding to
Uint8Array that doesn't rely on Buffer and also provides better error messages
on invalid input.

## Convert between bech32 and hex addresses

```
>> toBech32("tiov", fromHex("1234ABCD0000AA0000FFFF0000AA00001234ABCD"))
'tiov1zg62hngqqz4qqq8lluqqp2sqqqfrf27dzrrmea'
>> toHex(fromBech32("tiov1zg62hngqqz4qqq8lluqqp2sqqqfrf27dzrrmea").data)
'1234abcd0000aa0000ffff0000aa00001234abcd'
```

## License

This package is part of the cosmjs repository, licensed under the Apache License
2.0 (see [NOTICE](https://github.com/cosmos/cosmjs/blob/main/NOTICE) and
[LICENSE](https://github.com/cosmos/cosmjs/blob/main/LICENSE)).

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