# Formatting

WireBootstrap provides a number of options for string, numeric, and other type formatting. &#x20;

## String Formatting

WireBootstrap adds a string extension called `format` that allows variables inside a string expression to be replaced by values.  The variables are expressed using the numeric index position of the variables within the string in curly brackets `{}`.

```javascript
const str = "Use this {0} to format {1}".format("expression", "strings");

// Use this expression to format strings
```

## Number Formatting

Numeric values can be formatted using the `format` method with a format specification.  Valid values are *C\[N]*, *P\[N]*, *N\[N]* where *\[N]* is the number of decimal places.

The example below sets the formatting for a number to one decimal place using the `N1` parameter in the `format` function.&#x20;

```javascript
const currencyFormat = wire.format(10000.12, "N1");

// currencyFormat = 10,000.1
```

## Custom Formatting

The format method can also accept a custom function in order to format data. &#x20;

The following example formats a date field called `date_field` using the third party library [moment.js](https://momentjs.com).

```javascript
const dte = wire.format("1980-10-10", (row) => {
    return moment(row["date_field"]).format("MM-DD-YYYY");
});
```

For more on formatting, visit the [core wire](/wirebootstrap/reference/wire.md) reference page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/wirebootstrap/utilities/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
