Skip to main content

Getting Started

Get up and running with vn-number in minutes. This guide will walk you through installation and basic usage.
1 min read
Zero Dependencies

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.

Battle-Tested in Production

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#

Note

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:

Common Use Cases#

E-commerce Applications#

Banking and Financial Applications#

Data Visualization#