vn-number has zero runtime dependencies, making it lightweight and perfect for performance-critical applications. It uses the standard Intl.NumberFormat API for formatting, ensuring consistent behavior across all JavaScript environments without external dependencies.
This library is battle-tested in production apps and dashboards, providing reliable number formatting and reading for any applications that need to process Vietnamese numeric data.
Installation#
TypeScript Support
vn-number is written in TypeScript and includes type definitions out of the
box. No need to install separate @types packages!
Basic Usage#
Read Vietnamese Numbers#
Convert numbers to Vietnamese text:
Format Numbers in Vietnamese Style#
Format numbers with Vietnamese thousand separators (dots):
Format Vietnamese Currency (VND)#
Format numbers as Vietnamese Dong currency:
Format Percentages#
Format numbers as Vietnamese-style percentages:
Usage Examples#
Working with Large Numbers#
The library handles very large numbers using string or bigint:
Handling Invalid Input#
All formatting functions support fallback values:
Vietnamese Number Reading Rules#
The readVnNumber function follows Vietnamese language rules: