Playground
This page is the playground, published at the root of the project
site. It runs the package's own compiled functions, so build the
project with npm run build and serve the repository
over HTTP (for example npx http-server .), then open
/ locally. Opening the file directly with
file:// will not work, because browsers block module
loading from the filesystem.
What is arabic-kit?
arabic-kit is a lightweight JavaScript and TypeScript package for
Arabic number, digit, date, time and text formatting.
It formats numbers, converts Arabic digits inside text, renders
calendar dates and wall-clock times, and stretches Arabic text. It
is published on npm as arabic-kit and its source code
is on
GitHub.
The package has zero runtime dependencies, ships as
ESM only (there is no CommonJS build), and includes
TypeScript declaration files. Grouping and locale data are handled
with the built-in Intl API, so no polyfill or locale
file is needed. The whole public API is five functions:
number(), digits(), date(),
time() and stretch().
- npm package arabic-kit
- Repository github.com/Mohamed-0-Turki/arabic-kit
- License MIT
- Runtime dependencies none
- Module format ESM only
- TypeScript types included
- Node.js 18 or newer
-
Locale profiles
ar(ar-EG) anden(en-US)
The playground above runs these functions in your browser. Nothing is sent to a server: the page loads the compiled package and formats locally.
Functions
Each function has one job. Number formatting and digit conversion
are separate on purpose: number() formats a numeric
value, while digits() rewrites digits inside arbitrary
text.
number(value, options?)
Formats a number, a numeric string or a bigint. Grouping is applied
only to plain decimal numbers, so phone numbers, national IDs and
account numbers keep their digits. Options: locale,
digits, group.
number(123456, { locale: "ar", group: true }); // "١٢٣٬٤٥٦"
digits(value, style)
Converts Latin, Arabic-Indic and Persian digits inside any string to
the requested family, leaving letters, punctuation and separators
alone.
style is "arabic" or "latin".
digits("Order #2026", "arabic"); // "Order #٢٠٢٦"
date(value, options?)
Formats an ISO date string such as 2026-09-28 or a
Date. The default output keeps the
YYYY-MM-DD structure and uses the locale's digits;
month and weekday add localized month and
weekday names.
date("2026-09-28", { locale: "ar", month: "long" }); // "٢٨ سبتمبر ٢٠٢٦"
time(value, options?)
Formats a wall-clock string such as 18:30 or
18:30:45, with optional 12-hour output and the Arabic
period labels ص and م. Time strings are
never converted to a Date, so the output does not
depend on the timezone.
time("18:30", { locale: "ar", hour12: true }); // "٠٦:٣٠ م"
stretch(text, amount?)
Inserts the Arabic tatweel character between connecting letters so a
short label fills a fixed width. amount is the number
of tatweel characters added per join and defaults to 1.
stretch("مرحبا", 2); // "مــرحــبــا"
Install
npm install arabic-kit
import { date, digits, number, stretch, time } from "arabic-kit";
number(123456, { locale: "ar", group: true });
Each function is also available on its own subpath, for example
import { number } from "arabic-kit/number", so a
bundler can drop the code you do not use.
Links
- arabic-kit on npm — package page and installation instructions
- arabic-kit on GitHub — source code, issues and the full API documentation