# Json.stringify

Stringifies a value to its JSON representation, with support for `bigint`.

## Imports

:::code-group
```ts [Named]
import { Json } from 'ox'
```

```ts [Entrypoint]
import * as Json from 'ox/Json'
```
:::

## Examples

```ts twoslash
import { Json } from 'ox'

const json = Json.stringify({
  foo: 'bar',
  baz: 69420694206942069420694206942069420694206942069420n
})
// @log: '{"foo":"bar","baz":"69420694206942069420694206942069420694206942069420#__bigint"}'
```

## Definition

```ts
function stringify(
  value: any,
  replacer?: ((this: any, key: string, value: any) => any) | null,
  space?: string | number,
): string
```

**Source:** [src/core/Json.ts](https://github.com/wevm/ox/blob/main/src/core/Json.ts#L161)

## Parameters

### value

* **Type:** `any`

The value to stringify.

### replacer

* **Type:** `((this: any, key: string, value: any) => any) | null`
* **Optional**

A function that transforms the results. It is passed the key and value of the property, and must return the value to be used in the JSON string. If this function returns `undefined`, the property is not included in the resulting JSON string.

### space

* **Type:** `string | number`
* **Optional**

A string or number that determines the indentation of the JSON string. If it is a number, it indicates the number of spaces to use as indentation; if it is a string (e.g. `'\t'`), it uses the string as the indentation character.

## Return Type

The JSON string.

`string`
