# to-hex

> Convert values to hex string

Latest version **0.0.18** (published 2022-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-hex
pnpm add to-hex
yarn add to-hex
bun add to-hex
```

## Health

**Score 25/100 (F)** — status: abandoned.

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.18 |
| Published | 2022-03-30 |
| First published | 2019-06-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Miguel Mota |
| Maintainers | miguelmota |
| Keywords | normalize, hex, string, prefix, convert, types |

## Links

- npm: https://www.npmjs.com/package/to-hex
- Repository: https://github.com/miguelmota/to-hex
- Issues: https://github.com/miguelmota/to-hex/issues
- npm.io page: https://npm.io/package/to-hex

## Dependencies (2)

- [bignumber.js](https://npm.io/package/bignumber.js.md) 9.0.0
- [normalize-hex](https://npm.io/package/normalize-hex.md) 0.0.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.18 (latest) — 2022-03-30
- 0.0.17 — 2021-05-05
- 0.0.16 — 2020-11-18
- 0.0.15 — 2020-04-06
- 0.0.14 — 2020-04-04
- 0.0.13 — 2020-03-29
- 0.0.12 — 2020-03-29
- 0.0.11 — 2020-03-14
- 0.0.10 — 2020-03-14
- 0.0.9 — 2020-03-06
- 0.0.8 — 2020-03-06
- 0.0.7 — 2020-01-05
- 0.0.6 — 2020-01-05
- 0.0.5 — 2019-10-18
- 0.0.4 — 2019-07-12
- … 3 more at https://npm.io/package/to-hex/versions

## README

# to-hex

> Convert values to hex string

[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/miguelmota/to-hex/master/LICENSE)
[![NPM version](https://badge.fury.io/js/to-hex.svg)](http://badge.fury.io/js/to-hex)

## Install

```bash
npm install to-hex
```

## Getting started

```javascript
const toHex = require('to-hex')
const BN = require('bn.js')

console.log(toHex('abc')) // '616263'
console.log(toHex(Buffer.from('abc'))) // '616263'
console.log(toHex('abc', { addPrefix: true })) // '0x616263'
console.log(toHex(256)) // '100'
console.log(toHex('256')) // '100'
console.log(toHex(256, { evenLength: true })) // '0100'
console.log(toHex(new BN(256))) // '100'
console.log(toHex('0x1', { size: 8 })) // '00000001'
console.log(toHex(null, { addPrefix: true, evenLength: true, default: '0' })) // '0x00'

// treat decimal strings as regular strings and not numbers
console.log(toHex('256', { autoDetectString:false })) // '323536'
```

## Test

```bash
npm test
```

## License

[MIT](LICENSE)

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