> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Json

:::info
`Json` is a re-export of ox's [`Json`](https://oxlib.sh/api/Json). Refer to the ox documentation for the full reference.
:::

Utility functions for working with JSON (with support for `bigint`).

## Examples

Below are some examples demonstrating common usages of the `Json` module:

* [Stringifying JSON](#stringifying-json)

* [Parsing JSON](#parsing-json)

### Stringifying JSON

JSON values can be stringified (with `bigint` support) using [`Json.stringify`](/docs/utilities/json/stringify):

```ts twoslash
// @noErrors
import { Json } from 'viem/utils'

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

### Parsing JSON

JSON values can be parsed (with `bigint` support) using [`Json.parse`](/docs/utilities/json/parse):

```ts twoslash
// @noErrors
import { Json } from 'viem/utils'

const value = Json.parse(
  '{"foo":"bar","baz":69420694206942069420694206942069420694206942069420}'
)
// @log: { foo: 'bar', baz: 69420694206942069420694206942069420694206942069420n }
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Json.canonicalize`](/docs/utilities/json/canonicalize) | Serializes a value to a canonical JSON string as defined by [RFC 8785 (JSON Canonicalization Scheme)](https://www.rfc-editor.org/rfc/rfc8785). |
| [`Json.parse`](/docs/utilities/json/parse) | Parses a JSON string, with support for `bigint`. |
| [`Json.stringify`](/docs/utilities/json/stringify) | Stringifies a value to its JSON representation, with support for `bigint`. |

## Viem Helpers

Functions added by Viem on top of the `Json` module.

| Name | Description |
| ---- | ----------- |
| [`Json.prettyPrint`](/docs/utilities/json/prettyPrint) | Pretty-prints a JSON-like value into an aligned, human-readable block. |
