{"id":20118309,"url":"https://github.com/hckhanh/vn-number","last_synced_at":"2026-06-22T13:32:01.737Z","repository":{"id":224464406,"uuid":"763313268","full_name":"hckhanh/vn-number","owner":"hckhanh","description":"🛠 A bunch of utility functions that work with number in 🇻🇳 Vietnamese language","archived":false,"fork":false,"pushed_at":"2026-06-21T13:29:49.000Z","size":964,"stargazers_count":1,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-21T15:21:17.957Z","etag":null,"topics":["language","library","money","package","string","utilities","utility","vietnam","vietnamese","vietnamese-language"],"latest_commit_sha":null,"homepage":"https://vn-number.khanh.id","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hckhanh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-26T03:48:53.000Z","updated_at":"2026-06-13T20:09:54.000Z","dependencies_parsed_at":"2026-02-23T04:06:29.454Z","dependency_job_id":null,"html_url":"https://github.com/hckhanh/vn-number","commit_stats":null,"previous_names":["hckhanh/vn-number"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/hckhanh/vn-number","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hckhanh%2Fvn-number","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hckhanh%2Fvn-number/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hckhanh%2Fvn-number/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hckhanh%2Fvn-number/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hckhanh","download_url":"https://codeload.github.com/hckhanh/vn-number/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hckhanh%2Fvn-number/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34651747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["language","library","money","package","string","utilities","utility","vietnam","vietnamese","vietnamese-language"],"created_at":"2024-11-13T19:10:06.054Z","updated_at":"2026-06-22T13:32:01.732Z","avatar_url":"https://github.com/hckhanh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🇻🇳 vn-number [![NPM Downloads](https://img.shields.io/npm/dw/vn-number)](https://www.npmjs.com/package/vn-number) [![JSR](https://jsr.io/badges/@hckhanh/vn-number/weekly-downloads)](https://jsr.io/@hckhanh/vn-number)\n\n🛠 A bunch of utility functions that work with number in 🇻🇳 Vietnamese language\n\n[![Publish](https://github.com/hckhanh/vn-number/actions/workflows/publish.yml/badge.svg)](https://github.com/hckhanh/vn-number/actions/workflows/publish.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=hckhanh_vn-number\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=hckhanh_vn-number)\n[![codecov](https://codecov.io/gh/hckhanh/vn-number/graph/badge.svg?token=UG10IM2LLW)](https://codecov.io/gh/hckhanh/vn-number)\n[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/hckhanh/vn-number?utm_source=badge)\n\n## Features\n\n- Zero dependencies\n- Built-in support for Edge runtime\n- Typesafe with TypeScript\n- Fully documented\n- Works with `number`, `string`, and `bigint` types\n- Handles very large numbers (up to quintillions)\n- Battle-tested in production apps and dashboards\n\n## Installation\n\n```bash\npnpm add vn-number\n```\n\n```bash\ndeno add jsr:@hckhanh/vn-number\n```\n\n## Quick Start\n\n### Read Vietnamese Numbers\n\nConvert numbers to Vietnamese text:\n\n```ts\nimport { readVnNumber } from 'vn-number'\n\nreadVnNumber(1250000)\n// Output: \"một triệu hai trăm năm mươi nghìn\"\n\nreadVnNumber(15)\n// Output: \"mười lăm\"\n\nreadVnNumber(21)\n// Output: \"hai mươi mốt\"\n```\n\n### Format Numbers in Vietnamese Style\n\nFormat numbers with Vietnamese thousand separators (dots):\n\n```ts\nimport { formatVnNumber } from 'vn-number'\n\nformatVnNumber(1250000)\n// Output: \"1.250.000\"\n\nformatVnNumber(BigInt('9999999999999999'))\n// Output: \"9.999.999.999.999.999\"\n```\n\n### Format Vietnamese Currency (VND)\n\nFormat numbers as Vietnamese Dong currency:\n\n```ts\nimport { formatVnCurrency } from 'vn-number'\n\nformatVnCurrency(1250000)\n// Output: \"1.250.000 ₫\"\n\nformatVnCurrency(null, 'Không giới hạn')\n// Output: \"Không giới hạn\"\n```\n\n### Format Percentages\n\nFormat numbers as Vietnamese-style percentages:\n\n```ts\nimport { formatVnPercent } from 'vn-number'\n\nformatVnPercent(0.991)\n// Output: \"99,1%\"\n\nformatVnPercent(0.5)\n// Output: \"50%\"\n```\n\n## Documentation\n\nFor detailed documentation, examples, and API reference, visit:\n\n**[https://vn-number.khanh.id](https://vn-number.khanh.id)**\n\n## Common Use Cases\n\n### E-commerce\n\n```ts\nimport { formatVnCurrency, readVnNumber } from 'vn-number'\n\nconst price = 1500000\n\nconsole.log(formatVnCurrency(price))\n// Output: \"1.500.000 ₫\"\n\nconsole.log(readVnNumber(price))\n// Output: \"một triệu năm trăm nghìn\"\n```\n\n### Banking and Financial Documents\n\n```ts\nimport { readVnNumber, formatVnCurrency } from 'vn-number'\n\nconst amount = 2450000\n\nconsole.log(`Số tiền: ${formatVnCurrency(amount)}`)\n// Output: \"Số tiền: 2.450.000 ₫\"\n\nconsole.log(`Bằng chữ: ${readVnNumber(amount)} đồng`)\n// Output: \"Bằng chữ: hai triệu bốn trăm năm mươi nghìn đồng\"\n```\n\n### Data Visualization\n\n```ts\nimport { formatVnNumber, formatVnPercent } from 'vn-number'\n\nconst totalUsers = 1234567\nconst growthRate = 0.157\n\nconsole.log(`Tổng người dùng: ${formatVnNumber(totalUsers)}`)\n// Output: \"Tổng người dùng: 1.234.567\"\n\nconsole.log(`Tăng trưởng: ${formatVnPercent(growthRate)}`)\n// Output: \"Tăng trưởng: 15,7%\"\n```\n\n## Vietnamese Language Rules\n\nThe `readVnNumber` function follows Vietnamese language conventions:\n\n- **\"lăm\" rule**: 15 → \"mười lăm\", 25 → \"hai mươi lăm\"\n- **\"mốt\" rule**: 21 → \"hai mươi mốt\", 31 → \"ba mươi mốt\"\n- **\"lẻ\" rule**: 101 → \"một trăm lẻ một\", 305 → \"ba trăm lẻ năm\"\n- **Zero handling**: 1001 → \"một nghìn không trăm lẻ một\"\n\n## API Functions\n\n| Function | Description | Example |\n|----------|-------------|---------|\n| `readVnNumber(number)` | Convert number to Vietnamese text | `readVnNumber(1250000)` → `\"một triệu hai trăm năm mươi nghìn\"` |\n| `formatVnNumber(number, fallback?)` | Format number in Vietnamese style | `formatVnNumber(1250000)` → `\"1.250.000\"` |\n| `formatVnCurrency(money, fallback?)` | Format as VND currency | `formatVnCurrency(1250000)` → `\"1.250.000 ₫\"` |\n| `formatVnPercent(value, fallback?)` | Format as percentage | `formatVnPercent(0.991)` → `\"99,1%\"` |\n\n## Browser and Runtime Compatibility\n\n- ✅ Node.js 14+\n- ✅ Bun\n- ✅ Deno\n- ✅ Modern browsers (Chrome, Firefox, Safari, Edge)\n- ✅ React Native\n- ✅ Electron\n- ✅ Edge Runtime (Vercel, Cloudflare Workers, etc.)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT © [Khánh Hoàng](https://www.khanh.id)\n\n## Release Notes\n\nSee [Releases](https://github.com/hckhanh/vn-number/releases) for changelog and release notes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhckhanh%2Fvn-number","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhckhanh%2Fvn-number","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhckhanh%2Fvn-number/lists"}