Format Numbers

Number formatting for different needs. finance, length, size, etc.

Copy the Format Numbers <script> and paste into the <head> of your page

<!-- [WebTricks by CodeRaccoons] - Format NumbersĀ -->
<script async src="https://cdn.jsdelivr.net/gh/TheCodeRaccoons/WebTricks@1/Dist/Functional/FormatNumbers.min.js" ></script>
Copy Script

Required attributes

Optional
Defines the element containing the number to be formatted.
Attribute to add
Name
wt-formatnumber-element
Value
number
Instructions

Assign this attribute to the element that contains the number to format.

How does it look?
Optional
Specifies the locales to use for formatting (e.g., 'en-US').
Attribute to add
Name
wt-formatnumber-locales
Value
Instructions

Set this attribute to define the locale for formatting the number.

How does it look?
Optional
Specifies the unit for formatting when the style is set to 'unit'.
Attribute to add
Name
wt-formatnumber-unit
Value
Instructions

Set this attribute to define the unit when formatting as unit style.

How does it look?
Optional
Defines the style of formatting (e.g., currency, percent).
Attribute to add
Name
wt-formatnumber-style
Value
currency, decimal, percent, unit
Instructions

Set this attribute to specify the formatting style for the number.

How does it look?
Optional
Specifies the currency for formatting when the style is set to 'currency'.
Attribute to add
Name
wt-formatnumber-currency
Value
Instructions

Set this attribute to define the currency when formatting as currency.

How does it look?

Optional Attributes

No items found.

Working examples