---
updatedAt: 2025-05-20T20:28:43.000Z
agentTools:
  projectIndex: https://docs.documotor.com/llms.txt
---

# parse_json

Parse a JSON token from a string

# Definition

`any parse_json(string $string)`

Parses a string to yield a JSON token of any data type. Inverse of [`to_string`](https://docs.documotor.com/docs/to_string) function.

# Parameters

<Glossary>string</Glossary> `$string`

The string correctly formatted as a JSON token. If this is not the case, an error is raised.

# Returns

<Glossary>any</Glossary>

A JSON token that was represented by `$string`.

# Examples

```text Transformation
{
  a: parse_json('1'),
  b: parse_json('true'),
  c: parse_json('["apple", "banana"]'),
  d: parse_json('{name: "Jane", age: 30}'),
  e: parse_json('apple')           // Error, strings need to be enclosed in double quotes.
}
```

```json Result
{
  "a": 1,
  "b": true,
  "c": ["apple", "banana"],
  "d": {"name": "Jane", "age": 30}
}
```