# str-util

> convert full/half width, Chinese/Japanese number, 中日漢字轉換... others util helper

Latest version **3.0.5** (published 2026-09-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install str-util
pnpm add str-util
yarn add str-util
bun add str-util
```

## Health

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

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.5 |
| Published | 2026-09-11 |
| First published | 2017-12-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 15 |
| Unpacked size | 369.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | char, character, characters, chinese, cjk, cn, cn2tw, codepage, conv, conversion, convert, fullwidth, halfwidth, han, han zi, hanja, japanese, jp2zhs, jp2zht, kanji, node-novel, number, simplified, str, str-util, string, traditional, transform, trim, tw, tw2cn, unicode, util, words, zh, zh2jp, zhs, zht |

## Links

- npm: https://www.npmjs.com/package/str-util
- Repository: https://github.com/bluelovers/ws-string
- Homepage: https://github.com/bluelovers/ws-string/tree/master/packages/str-util#readme
- Issues: https://github.com/bluelovers/ws-string/issues
- npm.io page: https://npm.io/package/str-util

## Dependencies (15)

- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [cjk-conv](https://npm.io/package/cjk-conv.md) >=1
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.3.1
- [strip-ansi](https://npm.io/package/strip-ansi.md) <7 >=6
- [uni-string](https://npm.io/package/uni-string.md) ^2.0.10
- [@lazy-cjk/zh2num](https://npm.io/package/@lazy-cjk/zh2num.md) ^1.0.5
- [chinese-parseint2](https://npm.io/package/chinese-parseint2.md) ^2.0.12
- [@lazy-cjk/fullhalf](https://npm.io/package/@lazy-cjk/fullhalf.md) ^1.0.4
- [@lazy-cjk/japanese](https://npm.io/package/@lazy-cjk/japanese.md) ^1.2.39
- [@lazy-cjk/str-util-trim](https://npm.io/package/@lazy-cjk/str-util-trim.md) ^1.0.7
- [is-fullwidth-code-point](https://npm.io/package/is-fullwidth-code-point.md) <4 >=3
- [@lazy-cjk/jp-table-convert](https://npm.io/package/@lazy-cjk/jp-table-convert.md) ^1.0.55
- [@lazy-cjk/str-util-normalize](https://npm.io/package/@lazy-cjk/str-util-normalize.md) ^1.0.7
- [@lazy-cjk/jp-table-comparison](https://npm.io/package/@lazy-cjk/jp-table-comparison.md) ^1.0.35
- [@lazy-cjk/str-util-char-code-at](https://npm.io/package/@lazy-cjk/str-util-char-code-at.md) ^1.0.7

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 3.0.5 (latest) — 2026-09-11
- 3.0.4 — 2026-09-11
- 3.0.2 — 2024-02-03
- 3.0.1 — 2024-01-29
- 2.3.41 — 2023-11-24
- 2.3.40 — 2023-09-08
- 2.3.39 — 2023-04-12
- 2.3.38 — 2023-04-12
- 2.3.37 — 2022-11-01
- 2.3.36 — 2022-10-15
- 2.3.35 — 2022-09-26
- 2.3.34 — 2022-09-16
- 2.3.33 — 2022-08-27
- 2.3.31 — 2022-08-26
- 2.3.28 — 2022-01-17
- … 40 more at https://npm.io/package/str-util/versions

## README

# str-util

> convert full/half width, Chinese/Japanese number ... others util helper

## 安裝 (Installation)

```bash
# 使用 yarn / Using yarn
yarn add str-util

# 使用 yarn-tool / Using yarn-tool
yarn-tool add str-util
# yt 是 yarn-tool 的別名 / yt is an alias for yarn-tool
yt add str-util

# 使用 pnpm / Using pnpm
pnpm add str-util

# 使用 npm / Using npm
npm install str-util
```

## Usage

```javascript
import * as StrUtil from 'str-util';
```

See more at [test](https://github.com/bluelovers/node-str-util/tree/master/test) / [docs](https://bluelovers.github.io/node-str-util/)

### FullHalf

```javascript
const str = 'THE ｑｕｉｃｋ， ＢＲＯＷＮ\u3000fox.';

StrUtil.toFullWidth(str);
//=> 'ＴＨＥ　ｑｕｉｃｋ，　ＢＲＯＷＮ　ｆｏｘ．'

StrUtil.toHalfWidth(str);
//=> 'THE quick, BROWN fox.'

console.log(StrUtil.toFullEnglish('123abcABCＡＢＣ１２３／＊－＋＝－０］［’；／．+-*/=-09][\'";/.'));
console.log(StrUtil.toHalfEnglish('123abcABCＡＢＣ１２３／＊－＋＝－０］［’；／．+-*/=-09][\'";/.'));
console.log(StrUtil.toFullNumber('123abcABCＡＢＣ１２３／＊－＋＝－０］［’；／．+-*/=-09][\'";/.'));
console.log(StrUtil.toHalfNumber('123abcABCＡＢＣ１２３／＊－＋＝－０］［’；／．+-*/=-09][\'";/.'));
```

default
```
０１２３４５６７８９
0123456789
ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚ
abcdefghijklmnopqrstuvwxyz
　

！＂＃＄％＆＇（）＊＋，－．／：；＜＝＞？＠［＼］＾＿｀｛｜｝～
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
```

### 漢字 Number

```javascript
zh2num('千百十七') == 1117
num2zh(1117) == '千百十七'
```

### 中日漢字

```javascript
import { zh2jp } from 'str-util';

let t = '魔物解説　ランク等話　蚀蝕蝕王で触王 冒険者ギルド解説 蚀|蝕战|戦马|馬亚|亞國預中日漢字對照表'

console.log(zh2jp(t));
```

```javascript
import * as ZH2JP from 'str-util/lib/han/zh2jp';

// 沒有漢字存在時會直接返回原參數
console.log(ZH2JP.zhs2jp(1));

// http://ncode.syosetu.com/n1745ct/
let t = '魔物解説　ランク等話　蚀蝕蝕王で触王 冒険者ギルド解説 蚀|蝕战|戦马|馬亚|亞國預中日漢字對照表'

console.log(ZH2JP.zh2jp(t));
console.log(ZH2JP.zht2jp(t));
console.log(ZH2JP.zhs2jp(t));

console.log(ZH2JP.zht2zhs(t));
console.log(ZH2JP.zhs2zht(t));
```

## lib

* `ascii-fullwidth-halfwidth-convert`
* `string-width`
* `chinese-parseint`
* `japanese`

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