# Markdown Code Blocks in Confluence — 190+ Languages

September 24, 2026 ·

<!-- -->

4 min read

[NGPilot](https://ngpilot.com)

Every engineering page in Confluence eventually holds code — a curl from the runbook, the config that fixed the incident, the query the dashboard runs. And every one of those snippets has three natural enemies: the language dropdown in the macro dialog, the paste that loses its indentation, and the reader who cannot copy the thing without dragging across line numbers.

Markdown fences solve all three, because they make the code block *text you type* instead of an object you configure. ` ```bash `, paste, ` ``` ` — done, highlighted, copyable. This guide shows the syntax, the theming behavior, and when fences beat the native macro.

**Quick answer:** To add code blocks in Confluence with Markdown, install [Enhanced Markdown for Confluence](https://marketplace.atlassian.com/apps/1237026/enhanced-markdown-for-confluence) and use fenced blocks in its macro: ` ```java `, ` ```python `, ` ```bash ` — 190+ languages highlighted via highlight.js, GitHub light/dark themes that follow the page, and a copy button for every reader. Free for up to 10 users.

## The Syntax — One Fence, One Language Tag[​](#the-syntax--one-fence-one-language-tag "Direct link to The Syntax — One Fence, One Language Tag")

The whole grammar is the fence tag:

````
```bash

pnpm install && forge deploy

```
````

Three properties make this the fastest code-block route in Confluence:

1. **The tag selects the highlighter.** `java`, `python`, `sql`, `yaml`, `diff` — 190+ languages via highlight.js. No dropdown, no dialog, no mouse.
2. **It pastes clean from anywhere.** Code from a terminal, an editor, or a GitHub README carries its own fence — drop it in as-is.
3. **It stays portable.** Copy the fence back out and it works in a README, a PR description, or an LLM prompt. The block is text; the rendering is a property of the page, not the snippet.

## What the Render Gives Readers[​](#what-the-render-gives-readers "Direct link to What the Render Gives Readers")

The published block is not just colored text:

* **GitHub light and dark themes**, picked to match Confluence's palette — and the block follows the page theme automatically, so dark-mode readers get dark code instead of a white rectangle.
* **A copy button on every block** — one click onto the clipboard, no gutter-number cleanup, works for read-only viewers.
* **Live re-render while editing** — the split preview updates as you type, so a half-typed snippet never renders as a broken artifact.

## Copy-Paste Examples for the Four Usual Suspects[​](#copy-paste-examples-for-the-four-usual-suspects "Direct link to Copy-Paste Examples for the Four Usual Suspects")

A runbook command (`bash`), a config (`yaml`), a query (`sql`), and a bug report (`diff`):

````
```bash

curl -s -H "Authorization: Bearer $TOKEN" \

  https://api.example.com/v2/deployments?limit=5

```



```yaml

service:

  replicas: 3

  resources:

    requests: { cpu: "500m", memory: "512Mi" }

```



```sql

SELECT status, count(*) AS n

FROM deployments

WHERE created_at > now() - interval '7 days'

GROUP BY status

ORDER BY n DESC;

```



```diff

- timeout: 30

+ timeout: 90

+ retry: { max_attempts: 3 }

```
````

The `diff` fence is the quiet hero — before/after config changes render red and green, which turns "we changed the timeout" into something a reader can see.

## Fences vs the Native Code Macro[​](#fences-vs-the-native-code-macro "Direct link to Fences vs the Native Code Macro")

Both exist; they optimize for different moments:

| Moment                                     | Use                                        |
| ------------------------------------------ | ------------------------------------------ |
| Page is code-heavy, authored like a README | Markdown fences — typing speed, no dialogs |
| Single snippet on an otherwise-visual page | Native macro — no Markdown macro needed    |
| Snippet must live on GitHub too            | Fences — same syntax in both places        |
| Before/after config change                 | `diff` fence — color-coded in one block    |

The honest rule: the native macro is fine for one block. The moment a page holds three snippets — or the snippet also lives in a repo — fences win, because the block is text and text travels.

## Runbook Snippet, Start to Finish[​](#runbook-snippet-start-to-finish "Direct link to Runbook Snippet, Start to Finish")

The full loop, end to end: install [Enhanced Markdown for Confluence](https://marketplace.atlassian.com/apps/1237026/enhanced-markdown-for-confluence), type `/markdown` on the runbook page, paste the `bash` fence above, and republish. The next on-call reads highlighted, theme-correct, one-click-copyable code — and when the endpoint changes, you edit one line of text instead of re-screenshotting a block. Free for up to 10 users.

## Related Guides[​](#related-guides "Direct link to Related Guides")

* [Advanced Code Block Features in Confluence](/blog/advanced-code-blocks-confluence.md) — the macro route: performance tuning and per-block options
* [Display JSON, XML and Code in Confluence](/blog/display-json-xml-code-in-confluence.md) — structured payloads on documentation pages
* [Markdown FAQ: Syntax, Tables & Code Blocks in Confluence](/blog/faq-confluence-markdown-editor.md) — the cluster's reference page

Try <!-- -->Modern Code Blocks for Confluence

Monaco editor, 85+ languages (JSON, XML, YAML, SQL), 50+ themes, diff view, and auto dark/light mode — free for up to 10 users.

[Get it on the Atlassian Marketplace](https://marketplace.atlassian.com/apps/3525717923/modern-code-blocks-for-confluence?utm_source=ngpilot.com\&utm_medium=website\&utm_campaign=modern-code-blocks-for-confluence)

## Related guides

* [How to Create Mermaid Diagrams in Jira](/blog/how-to-create-mermaid-diagrams-jira.md)
* [Export Jira Issues to Excel or CSV](/blog/export-jira-issues-to-excel.md)
* [Bulk Download Jira Attachments](/blog/bulk-download-jira-attachments.md)
* [How to Migrate Confluence Content](/blog/how-to-migrate-confluence-content.md)
* [How to Add a Block Quote in Confluence](/blog/block-quote-confluence.md)

Explore NGPILOT[Browse Solutions](/solutions.md)[All Apps](/apps.md)[Atlassian Marketplace →](https://marketplace.atlassian.com/vendors/1226848/?utm_source=ngpilot.com\&utm_medium=blog\&utm_campaign=hub-links)

**Tags:**

* [confluence](/blog/tags/confluence.md)
* [markdown](/blog/tags/markdown.md)
* [code-block](/blog/tags/code-block.md)
* [syntax-highlighting](/blog/tags/syntax-highlighting.md)
* [how-to](/blog/tags/how-to.md)
* [developer-tools](/blog/tags/developer-tools.md)
