# ToString

Converts a value to a string.

## Method Signature

```
ToString(value=[any], encoding=[string])
```

### Arguments

| Argument   | Type     | Required | Description                                                                                                         | Default |
| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------- | ------- |
| `value`    | `any`    | `true`   | Value to convert to a string; can be a simple value such as an integer, a binary object, or an XML document object. |         |
| `encoding` | `string` | `false`  | The character encoding (character set) of the string, used with binary data.                                        |         |

## Examples

### Base64 value to binary to string

[Run Example](https://try.boxlang.io/?code=eJxLSixONTMJS8wpTVWwVSjJdwLzNRSUikuKMvPSwRJKCprWXEmZeYlFlUgKwXwNhSQkA4DKkLSBlQWD%2BUBlSNqBysqLMktS%2FUtLCkpLNBSQ9QDlAEx9Mf4%3D)

```java
base64Value = toBase64( "stringValue" );
binaryValue = toBinary( base64Value );
stringValue = toString( binaryValue );
writeOutput( stringValue );

```

Result: Expected Result: stringValue

### Structure to String

[Run Example](https://try.boxlang.io/?code=eJwrVrBVqFbg4lRKVFKwUlAyVNIBspPAbCMlrlprrvKizJJU%2F9KSgtISDYWS%2FOCSosy8dA2FYgVNBU1rLgDIOA%2FE)

```java
s = { 
	"a" : "1",
	"b" : "2"
};
writeOutput( toString( s ) );

```

Result: {a={1},b={2}}

### Member syntax

[Run Example](https://try.boxlang.io/?code=eJzLK81VsFUwMbLmKi%2FKLEn1Ly0pKC3RUMgrzdUryQ8uKcrMS9fQVNC05gIAHVcNNA%3D%3D)

```java
num = 42;
writeOutput( num.toString() );

```

Result: 42

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJwrL8osSXUpzS3QUCjJDy4pysxL11AwMVXQVNC05kopUbBVyMsv1wCyy7EpBCoAKwQAIS0VhQ%3D%3D)

```java
writeDump( toString( 45 ) );
dt = now();
writeDump( toString( dt ) );

```

[Run Example](https://try.boxlang.io/?code=eJzLK81NSi1SsFUoSsxLAeL0VA0FQx0FQwMFTWuu8qLMklSX0twCDYU8sDq9kvzgkqLMvHQNTZB8SglQY15%2BuQaq2pQSNHUAessf7Q%3D%3D)

```java
number = randrange( 1, 10 );
writeDump( number.toString() );
dt = now();
writeDump( dt.toString() );

```

## Related

* [DataNavigate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/datanavigate)
* [JSONDeserialize](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/jsondeserialize)
* [JSONPrettify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/jsonprettify)
* [JSONSerialize](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/jsonserialize)
* [LSParseNumber](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/lsparsenumber)
* [ParseNumber](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/parsenumber)
* [ToBase64](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/tobase64)
* [ToBinary](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/tobinary)
* [ToModifiable](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/tomodifiable)
* [ToNumeric](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/tonumeric)
* [ToScript](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/toscript)
* [ToUnmodifiable](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/conversion/tounmodifiable)
