Cosmo

Locale-aware formatting for JavaScript, PHP, Python, Java & C#.

Format money, dates, numbers, units and text using your users' locale conventions. Cosmo provides a shared API in five languages and reads locale data from ICU.

Implemented in — JavaScript · PHP · Python · Java · C#

Locale support from ICU

Cosmo uses ICU and CLDR locale data. Coverage depends on your runtime and ICU version:

150+ Languages English · Español · العربية · 中文 · हिन्दी · Русский
250+ Countries & regions 🇺🇸 United States · 🇩🇪 Deutschland · 🇯🇵 日本 · 🇪🇬 مصر
160+ Currencies $1,299.00 · €1.299,00 · ¥130,000 · ₹1,299.00 · ฿1,299.00
410+ Time zones New York · London · Tokyo · Kathmandu +5:45 · Chatham +12:45
18 Calendar systems Gregorian 2020 · Persian 1398 · Hebrew 5780 · Ethiopic 2012
150+ Scripts Latin · Кириллица · العربية · देवनागरी · 漢字 · ⵜⵉⴼⵉⵏⴰⵖ
75+ Numbering systems 2020 · ٢٠٢٠ · २०२० · ۲۰۲۰ · 二〇二〇
45+ Measurement units 2.19 GB · 5 km · 100 km/h · 3 L · 36.6 °C

From the everyday — US dollars, the Gregorian calendar, New York time, Latin script — to the long tail: the Persian and Ethiopic calendars, Nepal's UTC+5:45, the Adlam and Tifinagh scripts, and Eastern-Arabic numerals (٢٠٢٠).

⚡

Zero locale data

Language names, calendars, currencies and formatting rules come from ICU. Cosmo does not maintain its own locale tables.

🌍

The same API everywhere

Shared operations across JavaScript, PHP, Python, Java and C#, with naming and parameter types suited to each language. Choose your language in the header to read the relevant examples and guidance.

💱

Formatting and text tools

Money, dates, numbers, units, percentages, plurals, lists, ranges, collation, transliteration and parsing — all in the locale's conventions.

🧩

Runtime support

Available features depend on each language's ICU APIs. The platform notes explain which methods are supported and where behaviour differs.

Choose your language