Skip to main content
Formatters provide a powerful way to transform API responses and blockchain data into human-readable formats. WAX includes a flexible formatting system based on template literals.

Understanding formatters

WAX formatters allow you to:
  • Format numbers with locale-specific separators and precision
  • Transform asset amounts from satoshis to decimal values
  • Customize output based on data properties
  • Create reusable formatting rules
  • Match specific values with custom formatters
Formatters are primarily available in TypeScript. Python uses simpler formatting utilities.

Creating a formatter

The waxify function creates formatters for template literals.

Using waxify

The waxify function creates tagged template literals for formatting.

Formatting numbers

Format numbers with locale-specific separators and precision.
WAX formatters can handle numbers larger than JavaScript’s MAX_SAFE_INTEGER by working with string representations.

Formatting assets

Format cryptocurrency amounts from satoshis to human-readable values.

Custom formatters

Create custom formatters for specific data types or patterns.

Property matchers

Match specific property names for custom formatting.

Instance matchers

Match specific object types or classes.

Formatter options

Customize formatter behavior with options.

Complete example

Here’s a complete example using formatters to display account information.

Best practices

Template tags ensure consistent formatting across your application.
Group related formatting logic into reusable classes.
Always handle undefined, null, or invalid values.
If your app supports multiple locales, test formatting with each.

Next steps

Building transactions

Start building transactions with WAX

Complex operations

Use high-level operation helpers

TypeScript API

Explore the full API reference

Examples

See more formatting examples