# Format numbers as currency in a PDF

> If you're working in a details component on PDF pages and want to ensure a number is formatted as a currency field instead of number, here's a basic…

Source: https://tadabase.com/docs/learn/formatting-numbers-in-pdf-as-currency  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

If you're working in a details component on PDF pages and want to ensure a number is formatted as a currency field instead of number, here's a basic guide to doing this.

In the details component, open every field that should be formatted as a currency and add a class of 'currency'

![Screenshot for “Formatting Numbers in PDF as Currency~”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2024-07/scaled-1680-/image-1722366796197.png)

Then add this to Javascript

```javascript
window.onload = function() {
    var elements = document.querySelectorAll('.currency .t-pdf-details-value');
    for (var i in elements) {
        var element = elements[i];
        // Parse the text content to a number
        var number = parseFloat(element.textContent);

        // If the text content is a valid number, format it as currency
        if (!isNaN(number)) {
            // Format the number as currency and update the text content
            element.textContent = "$" + number.toFixed(2);
        }
    }
}
```
