> For the complete documentation index, see [llms.txt](https://docs.specifyapp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.specifyapp.com/reference/parsers/to-json-list.md).

# to-json-list

## Interface

```typescript
interface parser {
  name: "to-json-list";
  output:
    | {
        type: "file";
        filePath: string;
      }
    | { type: "JSON" };
  options?: {
    stringPathSeparator?: string;
  };
}

```

## Options

<table><thead><tr><th width="245">Parameter</th><th width="100">Required</th><th width="101">Type</th><th width="105">Default</th><th>Description</th></tr></thead><tbody><tr><td><code>stringPathSeparator</code></td><td><code>false</code></td><td><code>string</code></td><td><code>"."</code></td><td>Override the separator character used to build the string path property.</td></tr></tbody></table>

## Return type

The parser produces a custom data structure representing the flatten token tree.

```typescript
type FlattenNode = (
  | {
      kind: 'group';
    }
  | {
      kind: 'collection';
      modes: Array<string>;
    }
  | {
      kind: 'token';
      type: string;
      modeValues: Array<{
        mode: string;
        value: unknown;
      }>;
    }
) & {
  path: Array<string>;
  stringPath: string;
  name: string;
  description?: string;
  extensions?: unknown;
};

type ParserOutput = Array<FlattenNode>
```

## Basic usage

{% tabs %}
{% tab title="Input" %}
{% code lineNumbers="true" %}

```json
{
  "aCollection": {
    "$collection": {
      "$modes": ["light", "dark"]
    },
    "blue": {
      "$type": "color",
      "$value": {
        "light": {
          "model": "hex",
          "hex": "#0000CC",
          "alpha": 1
        },
        "dark": {
          "model": "hex",
          "hex": "#0000FF",
          "alpha": 1
        }
      }
    }
  },
  "aGroup": {
    "aDimension": {
      "$type": "dimension",
      "$value": {
        "default": {
          "unit": "px",
          "value": 16
        }
      }
    }
  }
}

```

{% endcode %}
{% endtab %}

{% tab title="Config" %}
{% code title=".specifyrc.json" lineNumbers="true" %}

```json
{
  "version": "2",
  "repository": "@organization/repository",
  // Only use the personalAccessToken when working with the CLI
  "personalAccessToken": "<your-personal-access-token>",
  "rules": [
    {
      "name": "To JSON",
      "parsers": [
        {
          "name": "to-json-list",
          "output": {
            "type": "file",
            "filePath": "tokens.json"
          }
        }
      ]
    }
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}
{% code title="tokens.json" lineNumbers="true" %}

```json
[
  {
    "path": [
      "aCollection"
    ],
    "stringPath": "aCollection",
    "name": "aCollection",
    "kind": "collection",
    "modes": [
      "light",
      "dark"
    ]
  },
  {
    "path": [
      "aCollection",
      "blue"
    ],
    "stringPath": "aCollection.blue",
    "name": "blue",
    "kind": "token",
    "type": "color",
    "modeValues": [
      {
        "mode": "dark",
        "value": {
          "model": "hex",
          "hex": "#0000FF",
          "alpha": 1
        }
      },
      {
        "mode": "light",
        "value": {
          "model": "hex",
          "hex": "#0000CC",
          "alpha": 1
        }
      }
    ]
  },
  {
    "path": [
      "aGroup"
    ],
    "stringPath": "aGroup",
    "name": "aGroup",
    "kind": "group"
  },
  {
    "path": [
      "aGroup",
      "aDimension"
    ],
    "stringPath": "aGroup.aDimension",
    "name": "aDimension",
    "kind": "token",
    "type": "dimension",
    "modeValues": [
      {
        "mode": "default",
        "value": {
          "value": 16,
          "unit": "px"
        }
      }
    ]
  }
]
```

{% endcode %}
{% endtab %}
{% endtabs %}
