---
title: Units
summary: Class in @bimworks/viewercommon.
order: 10
languages: [javascript]
sdk-package: JavaScript · @bimworks/viewercommon
---

# Units

[[page:reference/javascript/api|API catalogue]] · `@bimworks/viewercommon` · Class

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
class Units
````

Formats values with their units as the BIM.works UI shows them

## Members

| Member | Kind | Description |
|---|---|---|
| [[page:reference/javascript/bimworks-viewercommon/units-7f07a033#member-constructor-54a07e15404a|constructor]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/units-7f07a033#member-convertunit-339129272247|convertUnit]] | Method | The display postfix of a unit ("m²" for SQUARE_METRE); unknown units are returned as they are |
| [[page:reference/javascript/bimworks-viewercommon/units-7f07a033#member-itemtostring-81edcfba04c3|itemToString]] | Method | A value of any kind (number, string, value with unit, list) as text |
| [[page:reference/javascript/bimworks-viewercommon/units-7f07a033#member-tostring-175c5bf651c4|toString]] | Method | The value with its unit, "[No value]" for null |
| [[page:reference/javascript/bimworks-viewercommon/units-7f07a033#member-valuetostring-f4fa003fd8da|valueToString]] | Method | A feature's value with its unit or symbol (as a BVL label carries it) as text: a yes/no as "true" or "false", a number in a unit with its decimals and postfi… |

## `constructor` {#member-constructor-54a07e15404a}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
constructor()
````



## `convertUnit` {#member-convertunit-339129272247}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
static convertUnit(unit: string): string
````

The display postfix of a unit ("m²" for SQUARE_METRE); unknown units are returned as they are

### Parameters

| Name | Type | Description |
|---|---|---|
| `unit` | `string` |  |

## `itemToString` {#member-itemtostring-81edcfba04c3}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
static itemToString(item: unknown): string
````

A value of any kind (number, string, value with unit, list) as text

### Parameters

| Name | Type | Description |
|---|---|---|
| `item` | `unknown` |  |

## `toString` {#member-tostring-175c5bf651c4}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
static toString(value: string | number | null | undefined, unit?: string): string
````

The value with its unit, "[No value]" for null

### Parameters

| Name | Type | Description |
|---|---|---|
| `value` | `string \| number \| null \| undefined` |  |
| `unit` | `string` |  |

## `valueToString` {#member-valuetostring-f4fa003fd8da}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
static valueToString(value: string | number | boolean | null | undefined, unit?: string | null, symbol?: string | null): string
````

A feature's value with its unit or symbol (as a BVL label carries it) as text: a yes/no as "true" or "false",
a number in a unit with its decimals and postfix, a number without one (or UNITLESS) with two decimals at
most, "" for null

### Parameters

| Name | Type | Description |
|---|---|---|
| `value` | `string \| number \| boolean \| null \| undefined` |  |
| `unit` | `string \| null` |  |
| `symbol` | `string \| null` |  |
