Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Ffrombase.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Ffrombase.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `fromBase`

## Description

Converts a string representation of a number in a given base into its numeric value.

For example, `"101"` in base `2` becomes `5` in base `10`.

## Syntax

Like many functions in DataPrime, `fromBase` supports<!-- --> [two notations](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
fromBase(string: string, radix: number): number
```

```
(string: string).fromBase(radix: number): number
```

## Arguments

| Name     | Type     | Required | Description                                                           |
| -------- | -------- | -------- | --------------------------------------------------------------------- |
| `string` | `string` | **true** | The string containing the number                                      |
| `radix`  | `number` | **true** | The base of the string representation (e.g. hexadecimal is base `16`) |

## Example

**Use case: Parse a hexadecimal string**

Convert a hexadecimal string to a numeric value so it can be used in calculations.

### Example data

```
{

    "hex_value": "FF00FF"

}
```

### Example query

* Function notation
* Method notation

```
create num_value from fromBase(hex_value, 16)
```

```
create num_value from hex_value.fromBase(16)
```

### Example output

```
{

    "hex_value": "FF00FF",

    "num_value": 16711935

}
```
