> For the complete documentation index, see [llms.txt](https://docs.borndigital.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.borndigital.ai/digital-agent/advanced-functions/code-editor.md).

# Code editor

The YAML code behind every flow: reading it, editing it, keeping it in sync with the flow editor, copying it and comparing versions.

Every flow is also stored as **YAML code** – the format the platform trains and runs. Studio writes it for you from the flow editor, so most projects never need to touch it. Open it in **Design** › **Code editor** to read it, copy it or compare versions.

<figure><img src="https://4261467870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6iQTvxgRZRwPS1NgIGEb%2Fuploads%2Fgit-blob-dc9cb13203b2cee29b514e0d38d0911b55508a6d%2Fui-basics-code-editor.png?alt=media" alt="The Code editor with the YAML of the flow, YAML synced turned on, and Copy YAML and Show changes highlighted in the top bar; IDs are blurred"><figcaption><p>The Code editor</p></figcaption></figure>

## What the YAML contains

* **configuration** – the project settings from **File** › **Settings**, see [Setting tab](/digital-agent/conversation-flow/setting-tab.md).
* **flow** – every node under its name, with what it sets, says and where it goes next. For example, the goodbye message of the [tutorial](/digital-agent/building-new-projects.md):

```yaml
  MSG_GOODBYE:
    SET: []
    "1":
      MARKDOWN: Thank you for chatting with us. Goodbye!
      SPEECH: Thank you for chatting with us. Goodbye!
    GOTO: END_DONE
```

`MARKDOWN` is the chat text, `SPEECH` the text read out in calls and `GOTO` the next node. Some nodes produce more than one YAML block – an Answer node, for example, also gets a block with its chat buttons and timeouts.

## YAML synced

The **YAML synced** switch in the top bar decides which one is the source of the project:

* **On** (default) – the flow editor is the source. Changes in the flow are written to the YAML; changes you make in the YAML are turned back into the flow when Studio can read them.
* **Off** – your own YAML is used for training, and the top bar changes colour as a reminder.

When you edit the YAML and Studio cannot turn it into the flow, it shows **YAML out of sync with flow** and lists the nodes it could not understand. Confirm to keep your YAML as the source for training (the switch turns off), or do not confirm – then the flow stays the source and the YAML is written from the flow again.

Turning the switch back on asks you to **Synchronise flow editor and code editor**: the YAML is written from the flow again, and **anything in the YAML that the flow editor cannot show is lost**.

{% hint style="danger" %}
Work with **YAML synced** turned on. Use your own YAML only when you need something the flow editor cannot express, and agree on it with your team – while the switch is off, the YAML is what gets trained, not what you see in the flow editor.
{% endhint %}

## Errors in the YAML

When the YAML contains errors, Studio shows **Found errors in YAML file** and a red error button appears in the bottom bar. It opens **Errors and warnings in YAML**. **Save**, **Save version** and **Export** are blocked until the errors are fixed.

## Copy and compare

* **Copy YAML** copies the whole YAML to the clipboard – **including the values of secret variables**, so do not paste it into tickets, chats or e-mails.
* **Show changes** opens **Show difference in YAMLs**. Choose a version in **Select version** to compare the YAML you are working on with it. Unchanged parts are folded – click **Expand … lines** to see them.

<figure><img src="https://4261467870-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6iQTvxgRZRwPS1NgIGEb%2Fuploads%2Fgit-blob-dc05b7a7069bead7ccae98a3b5cc0fa92c2a9dc3%2Fcode-editor-show-changes.png?alt=media" alt="The Show difference in YAMLs dialog with Select version 0.1 and the folded unchanged part Expand 254 lines"><figcaption><p>Comparing with another version – here without differences</p></figcaption></figure>

To export or import the YAML as a file, use **File** › **Export** › **YAML** and **File** › **Import** › **YAML**, see [User Interface Basics](/digital-agent/conversation-flow/user-interface-basics.md#file-menu).
