---
title: TO_MARKDOWN_CODEBLOCK
url: https://www.tines.com/stories/docs/formulas/functions/to-markdown-codeblock/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/stories/docs/llms.txt) › [Formulas](https://www.tines.com/llm/stories/docs/formulas.md) › [Functions](https://www.tines.com/llm/stories/docs/formulas/functions.md)*

# TO_MARKDOWN_CODEBLOCK

*[View on tines.com](https://www.tines.com/stories/docs/formulas/functions/to-markdown-codeblock/)*

Format text as a fenced markdown code block, with an optional language for syntax highlighting. The fence is lengthened past the longest run of backticks in the text, so content that itself contains a fenced block cannot close the block early.

**Categories:** Text

## Syntax

```
TO_MARKDOWN_CODEBLOCK(text, [language])
```

## Examples

### Example 1

Input:

```json
{
  "my_action": {
    "snippet": "print('hello')"
  }
}
```

Formula:

```
TO_MARKDOWN_CODEBLOCK(my_action.snippet, "python")
```

Output:

```json
"```python\nprint('hello')\n```"
```

### Example 2: The language is optional.

Input:

```json
{
  "my_action": {
    "snippet": "print('hello')"
  }
}
```

Formula:

```
TO_MARKDOWN_CODEBLOCK(my_action.snippet)
```

Output:

```json
"```\nprint('hello')\n```"
```
